diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2015-12-15 09:35:42 +0100 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2015-12-15 09:35:42 +0100 |
commit | 7cd491796a2d6cc7102073344cbed8f94b8ed92c (patch) | |
tree | 52132b12f116dc8f6a1a157dc6d11fb1feaf9d33 /actionpack/test/controller | |
parent | cd90f4f273071fd20ff6e4ce34c33171923733b4 (diff) | |
parent | 99caf9ae7e46d15a713d821fa8cd516a4d254446 (diff) | |
download | rails-7cd491796a2d6cc7102073344cbed8f94b8ed92c.tar.gz rails-7cd491796a2d6cc7102073344cbed8f94b8ed92c.tar.bz2 rails-7cd491796a2d6cc7102073344cbed8f94b8ed92c.zip |
Merge pull request #22595 from sstephenson/fragment_cache_key
Controller-wide fragment cache key prefixes
Diffstat (limited to 'actionpack/test/controller')
-rw-r--r-- | actionpack/test/controller/caching_test.rb | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/actionpack/test/controller/caching_test.rb b/actionpack/test/controller/caching_test.rb index bc0ffd3eaa..d19b3810c2 100644 --- a/actionpack/test/controller/caching_test.rb +++ b/actionpack/test/controller/caching_test.rb @@ -419,3 +419,28 @@ class AutomaticCollectionCacheTest < ActionController::TestCase assert_equal 1, @controller.partial_rendered_times end end + +class FragmentCacheKeyTestController < CachingController + attr_accessor :account_id + + fragment_cache_key "v1" + fragment_cache_key { account_id } +end + +class FragmentCacheKeyTest < ActionController::TestCase + def setup + super + @store = ActiveSupport::Cache::MemoryStore.new + @controller = FragmentCacheKeyTestController.new + @controller.perform_caching = true + @controller.cache_store = @store + end + + def test_fragment_cache_key + @controller.account_id = "123" + assert_equal 'views/v1/123/what a key', @controller.fragment_cache_key('what a key') + + @controller.account_id = nil + assert_equal 'views/v1//what a key', @controller.fragment_cache_key('what a key') + end +end |