Skip to content

Instantly share code, notes, and snippets.

@ches
Created February 24, 2012 10:22
Show Gist options
  • Select an option

  • Save ches/1899982 to your computer and use it in GitHub Desktop.

Select an option

Save ches/1899982 to your computer and use it in GitHub Desktop.
ActionController caching context manager for testing
# Via raggi: http://stackoverflow.com/questions/5035982/optionally-testing-caching-in-rails-3-functional-tests
module ActionController::Testing::Caching
def with_caching(on = true)
caching = ActionController::Base.perform_caching
ActionController::Base.perform_caching = on
yield
ensure
ActionController::Base.perform_caching = caching
end
def without_caching(&block)
with_caching(false, &block)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment