aboutsummaryrefslogtreecommitdiffstats
path: root/actionview
diff options
context:
space:
mode:
authorJohn Hawthorn <john@hawthorn.email>2019-03-18 10:13:35 -0700
committerJohn Hawthorn <john@hawthorn.email>2019-03-18 11:12:22 -0700
commitffc842a09927986819cf7a66ae6a15f97bfeed76 (patch)
tree17522f7c287d5fd4f8d2a1a8a2e1cc9dd926af19 /actionview
parentc555e28a4cf3690a95b5ed108d174f39cedd19b1 (diff)
downloadrails-ffc842a09927986819cf7a66ae6a15f97bfeed76.tar.gz
rails-ffc842a09927986819cf7a66ae6a15f97bfeed76.tar.bz2
rails-ffc842a09927986819cf7a66ae6a15f97bfeed76.zip
Make uniq in LookupContext#formats=
Having a format listed twice had no effect. This is mostly helpful to avoid an extra format when assigning [:html, "*/*"]
Diffstat (limited to 'actionview')
-rw-r--r--actionview/lib/action_view/lookup_context.rb2
-rw-r--r--actionview/test/template/lookup_context_test.rb2
2 files changed, 3 insertions, 1 deletions
diff --git a/actionview/lib/action_view/lookup_context.rb b/actionview/lib/action_view/lookup_context.rb
index a0a2d41948..41751c2963 100644
--- a/actionview/lib/action_view/lookup_context.rb
+++ b/actionview/lib/action_view/lookup_context.rb
@@ -282,6 +282,8 @@ module ActionView
if values
values = values.compact
values.concat(default_formats) if values.delete "*/*"
+ values.uniq!
+
if values == [:js]
values << :html
@html_fallback_for_js = true
diff --git a/actionview/test/template/lookup_context_test.rb b/actionview/test/template/lookup_context_test.rb
index 8b61302c32..ce5b4c4f66 100644
--- a/actionview/test/template/lookup_context_test.rb
+++ b/actionview/test/template/lookup_context_test.rb
@@ -72,7 +72,7 @@ class LookupContextTest < ActiveSupport::TestCase
test "handles explicitly defined */* formats fallback to :js" do
@lookup_context.formats = [:js, Mime::ALL]
- assert_equal [:js, *Mime::SET.symbols], @lookup_context.formats
+ assert_equal [:js, *Mime::SET.symbols].uniq, @lookup_context.formats
end
test "adds :html fallback to :js formats" do