aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/controller/caching_test.rb
diff options
context:
space:
mode:
authorJamis Buck <jamis@37signals.com>2013-01-08 11:20:47 -0700
committerJamis Buck <jamis@37signals.com>2013-01-08 11:20:47 -0700
commit70e684a681352e95fb990747ef6dd7183da333a8 (patch)
tree59ea8b888d7bc9c99cdcfab3ad4bf0f346244054 /actionpack/test/controller/caching_test.rb
parentac86cbec82acee18a5066e00b98d1c20fc677a15 (diff)
downloadrails-70e684a681352e95fb990747ef6dd7183da333a8.tar.gz
rails-70e684a681352e95fb990747ef6dd7183da333a8.tar.bz2
rails-70e684a681352e95fb990747ef6dd7183da333a8.zip
view_cache_dependency API
A declarative API for specifying dependencies that affect template cache digest computation. In your controller, specify any of said dependencies: view_cache_dependency { "phone" if using_phone? } When the block is evaluated, the resulting value is included in the cache digest calculation, allowing you to generate different digests for effectively the same template. (Mostly useful if you're mucking with template load paths.)
Diffstat (limited to 'actionpack/test/controller/caching_test.rb')
-rw-r--r--actionpack/test/controller/caching_test.rb18
1 files changed, 18 insertions, 0 deletions
diff --git a/actionpack/test/controller/caching_test.rb b/actionpack/test/controller/caching_test.rb
index 2428cd7433..eb5eeb0423 100644
--- a/actionpack/test/controller/caching_test.rb
+++ b/actionpack/test/controller/caching_test.rb
@@ -296,6 +296,24 @@ class CacheHelperOutputBufferTest < ActionController::TestCase
end
end
+class ViewCacheDependencyTest < ActionController::TestCase
+ class NoDependenciesController < ActionController::Base
+ end
+
+ class HasDependenciesController < ActionController::Base
+ view_cache_dependency { "trombone" }
+ view_cache_dependency { "flute" }
+ end
+
+ def test_view_cache_dependencies_are_empty_by_default
+ assert NoDependenciesController.view_cache_dependencies.empty?
+ end
+
+ def test_view_cache_dependencies_are_listed_in_declaration_order
+ assert_equal %w(trombone flute), HasDependenciesController.view_cache_dependencies
+ end
+end
+
class DeprecatedPageCacheExtensionTest < ActiveSupport::TestCase
def test_page_cache_extension_binds_default_static_extension
deprecation_behavior = ActiveSupport::Deprecation.behavior