diff options
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/lib/action_view/lookup_context.rb | 11 | ||||
-rw-r--r-- | actionpack/test/template/lookup_context_test.rb | 5 |
2 files changed, 12 insertions, 4 deletions
diff --git a/actionpack/lib/action_view/lookup_context.rb b/actionpack/lib/action_view/lookup_context.rb index 06975ffa2f..02114f46da 100644 --- a/actionpack/lib/action_view/lookup_context.rb +++ b/actionpack/lib/action_view/lookup_context.rb @@ -169,10 +169,13 @@ module ActionView # Overload formats= to reject ["*/*"] values. def formats=(values) - if values && values.size == 1 - value = values.first - values = nil if value == "*/*" - values << :html if value == :js + if values + values.pop if values.last == "*/*" + if values.size == 0 + values = nil + elsif values == [:js] + values << :html + end end super(values) end diff --git a/actionpack/test/template/lookup_context_test.rb b/actionpack/test/template/lookup_context_test.rb index 5fb1fdc044..e7680bc022 100644 --- a/actionpack/test/template/lookup_context_test.rb +++ b/actionpack/test/template/lookup_context_test.rb @@ -51,6 +51,11 @@ class LookupContextTest < ActiveSupport::TestCase assert_equal Mime::SET, @lookup_context.formats end + test "handles explicitly defined */* formats fallback to :js" do + @lookup_context.formats = [:js, Mime::ALL] + assert_equal [:js, :html], @lookup_context.formats + end + test "adds :html fallback to :js formats" do @lookup_context.formats = [:js] assert_equal [:js, :html], @lookup_context.formats |