aboutsummaryrefslogtreecommitdiffstats
path: root/actionview
diff options
context:
space:
mode:
authorKasper Timm Hansen <kaspth@gmail.com>2015-09-26 23:06:56 +0200
committerKasper Timm Hansen <kaspth@gmail.com>2015-09-26 23:06:56 +0200
commit1d02cba939965272483a4bed8fe3d7dbabeafdaf (patch)
treedcbebc0ae362192dd5b5678abbe02330e64dfac5 /actionview
parentee824c8858f2a14aa3014877310971795348e460 (diff)
parent5e32b90245063c9644627e96f6e6df73aa19d7f0 (diff)
downloadrails-1d02cba939965272483a4bed8fe3d7dbabeafdaf.tar.gz
rails-1d02cba939965272483a4bed8fe3d7dbabeafdaf.tar.bz2
rails-1d02cba939965272483a4bed8fe3d7dbabeafdaf.zip
Merge pull request #21781 from ronakjangir47/partial_caching_test
Added test cases where collection partial cached & rendered with different keys
Diffstat (limited to 'actionview')
-rw-r--r--actionview/test/template/render_test.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/actionview/test/template/render_test.rb b/actionview/test/template/render_test.rb
index 9c2c9507b7..00fc28a522 100644
--- a/actionview/test/template/render_test.rb
+++ b/actionview/test/template/render_test.rb
@@ -627,6 +627,16 @@ class CachedCollectionViewRenderTest < CachedViewRenderTest
@view.render(partial: "test/customer", collection: [customer], cache: ->(item) { [item, 'key'] })
end
+ test "with caching with custom key and rendering with different key" do
+ customer = Customer.new("david")
+ key = cache_key([customer, 'key'], "test/_customer")
+
+ ActionView::PartialRenderer.collection_cache.write(key, 'Hello')
+
+ assert_equal "Hello: david",
+ @view.render(partial: "test/customer", collection: [customer], cache: ->(item) { [item, 'another_key'] })
+ end
+
test "automatic caching with inferred cache name" do
customer = CachedCustomer.new("david")
key = cache_key(customer, "test/_cached_customer")