From 53e4055a75fc16bf31aeb295ec18c07a3059db57 Mon Sep 17 00:00:00 2001 From: John Hawthorn Date: Fri, 12 Apr 2019 10:20:04 -0700 Subject: Support disabling cache for Digestor This adds a bit of complexity, but is necessary for now to avoid holding extra copies of templates which are resolved from ActionView::Digestor after disabling cache on the lookup context. --- actionview/test/template/resolver_shared_tests.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'actionview/test') diff --git a/actionview/test/template/resolver_shared_tests.rb b/actionview/test/template/resolver_shared_tests.rb index 37bdf4b22c..ee73ec1922 100644 --- a/actionview/test/template/resolver_shared_tests.rb +++ b/actionview/test/template/resolver_shared_tests.rb @@ -95,6 +95,20 @@ module ResolverSharedTests assert_same a, b end + def test_different_templates_when_cache_disabled + with_file "test/hello_world.html.erb", "Hello HTML!" + + a = context.find("hello_world", "test", false, [], {}) + b = context.disable_cache { context.find("hello_world", "test", false, [], {}) } + c = context.find("hello_world", "test", false, [], {}) + + # disable_cache should give us a new object + refute_same a, b + + # but it should not clear the cache + assert_same a, c + end + def test_same_template_from_different_details_is_same_object with_file "test/hello_world.html.erb", "Hello plain text!" -- cgit v1.2.3