diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2014-03-14 14:58:34 -0300 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2014-03-14 14:58:34 -0300 |
commit | 274d5e45e00f6bddab8fecceccad3ba6c1c66232 (patch) | |
tree | 906e38aa4cbfb86dd3dcfa519d48bcd2c1853ffa /actionpack/test | |
parent | b4c96490eeb1fbb944e116c7703dd528b37fc08a (diff) | |
parent | 2c2326e6eab4d192e361871787335ffa711af597 (diff) | |
download | rails-274d5e45e00f6bddab8fecceccad3ba6c1c66232.tar.gz rails-274d5e45e00f6bddab8fecceccad3ba6c1c66232.tar.bz2 rails-274d5e45e00f6bddab8fecceccad3ba6c1c66232.zip |
Merge pull request #14329 from pch/digestor-lookup-fix
Ensure LookupContext in Digestor selects correct variant
Diffstat (limited to 'actionpack/test')
-rw-r--r-- | actionpack/test/controller/caching_test.rb | 21 | ||||
-rw-r--r-- | actionpack/test/fixtures/functional_caching/formatted_fragment_cached_with_variant.html+phone.erb | 3 |
2 files changed, 24 insertions, 0 deletions
diff --git a/actionpack/test/controller/caching_test.rb b/actionpack/test/controller/caching_test.rb index 591d0eccc3..9923b90bae 100644 --- a/actionpack/test/controller/caching_test.rb +++ b/actionpack/test/controller/caching_test.rb @@ -164,6 +164,13 @@ class FunctionalCachingController < CachingController end end + def formatted_fragment_cached_with_variant + respond_to do |format| + format.html.phone + format.html + end + end + def fragment_cached_without_digest end end @@ -242,6 +249,20 @@ CACHED @store.read("views/test.host/functional_caching/formatted_fragment_cached/#{template_digest("functional_caching/formatted_fragment_cached", "xml")}") end + + def test_fragment_caching_with_variant + @request.variant = :phone + + get :formatted_fragment_cached_with_variant, :format => "html" + assert_response :success + expected_body = "<body>\n<p>PHONE</p>\n</body>\n" + + assert_equal expected_body, @response.body + + assert_equal "<p>PHONE</p>", + @store.read("views/test.host/functional_caching/formatted_fragment_cached_with_variant/#{template_digest("functional_caching/formatted_fragment_cached_with_variant", :html, :phone)}") + end + private def template_digest(name, format, variant = nil) ActionView::Digestor.digest(name: name, format: format, variant: variant, finder: @controller.lookup_context) diff --git a/actionpack/test/fixtures/functional_caching/formatted_fragment_cached_with_variant.html+phone.erb b/actionpack/test/fixtures/functional_caching/formatted_fragment_cached_with_variant.html+phone.erb new file mode 100644 index 0000000000..e523b74ae3 --- /dev/null +++ b/actionpack/test/fixtures/functional_caching/formatted_fragment_cached_with_variant.html+phone.erb @@ -0,0 +1,3 @@ +<body> +<%= cache do %><p>PHONE</p><% end %> +</body> |