aboutsummaryrefslogtreecommitdiffstats
path: root/actionview/lib/action_view/helpers
diff options
context:
space:
mode:
authorPiotr Chmolowski <piotr@chmolowski.pl>2014-03-08 23:09:54 +0100
committerPiotr Chmolowski <piotr@chmolowski.pl>2014-03-09 08:47:17 +0100
commit025c691536b22cc3f0ba802f6c303dd6f955c1c3 (patch)
tree05f18a57f6c48db8528f08bed3cac3096be91f6b /actionview/lib/action_view/helpers
parent45efd0ebf77811e43cebc68400c24652133a0f99 (diff)
downloadrails-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 'actionview/lib/action_view/helpers')
-rw-r--r--actionview/lib/action_view/helpers/cache_helper.rb18
1 files changed, 14 insertions, 4 deletions
diff --git a/actionview/lib/action_view/helpers/cache_helper.rb b/actionview/lib/action_view/helpers/cache_helper.rb
index 30e4e5e329..3177d18c4d 100644
--- a/actionview/lib/action_view/helpers/cache_helper.rb
+++ b/actionview/lib/action_view/helpers/cache_helper.rb
@@ -165,10 +165,20 @@ module ActionView
def fragment_name_with_digest(name) #:nodoc:
if @virtual_path
- [
- *Array(name.is_a?(Hash) ? controller.url_for(name).split("://").last : name),
- Digestor.digest(name: @virtual_path, format: formats.last.to_sym, variant: request.variant, finder: lookup_context, dependencies: view_cache_dependencies)
- ]
+ variant = request.variant.is_a?(Array) ? request.variant.first : request.variant
+
+ options = {
+ name: @virtual_path,
+ format: formats.last.to_sym,
+ variant: variant,
+ finder: lookup_context,
+ dependencies: view_cache_dependencies
+ }
+
+ names = Array(name.is_a?(Hash) ? controller.url_for(name).split("://").last : name)
+ digest = Digestor.digest(options)
+
+ [*names, digest]
else
name
end