diff options
author | Piotr Chmolowski <piotr@chmolowski.pl> | 2014-03-08 23:09:54 +0100 |
---|---|---|
committer | Piotr Chmolowski <piotr@chmolowski.pl> | 2014-03-09 08:47:17 +0100 |
commit | 025c691536b22cc3f0ba802f6c303dd6f955c1c3 (patch) | |
tree | 05f18a57f6c48db8528f08bed3cac3096be91f6b /actionpack/test/controller | |
parent | 45efd0ebf77811e43cebc68400c24652133a0f99 (diff) | |
download | rails-025c691536b22cc3f0ba802f6c303dd6f955c1c3.tar.gz rails-025c691536b22cc3f0ba802f6c303dd6f955c1c3.tar.bz2 rails-025c691536b22cc3f0ba802f6c303dd6f955c1c3.zip |
Ensure LookupContext in Digestor selects correct variant
Related to: #14242 #14243 14293
Variants passed to LookupContext#find() seem to be ignored, so
I've used the setter instead: `finder.variants = [ variant ]`.
I've also added some more test cases for variants. Hopefully this
time passing tests will mean it actually works.
Diffstat (limited to 'actionpack/test/controller')
-rw-r--r-- | actionpack/test/controller/caching_test.rb | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/actionpack/test/controller/caching_test.rb b/actionpack/test/controller/caching_test.rb index 591d0eccc3..0ba8045cb5 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", :variant => :phone + 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) |