Always expand */*
This commit is contained in:
parent
fadd1fa3d3
commit
0a1ba4eab0
|
@ -167,15 +167,12 @@ module ActionView
|
|||
@frozen_formats = true
|
||||
end
|
||||
|
||||
# Overload formats= to reject ["*/*"] values.
|
||||
# Overload formats= to expand ["*/*"] values and automatically
|
||||
# add :html as fallback to :js.
|
||||
def formats=(values)
|
||||
if values
|
||||
values.pop if values.last == "*/*"
|
||||
if values.size == 0
|
||||
values = nil
|
||||
elsif values == [:js]
|
||||
values << :html
|
||||
end
|
||||
values.concat(_formats_defaults) if values.delete "*/*"
|
||||
values << :html if values == [:js]
|
||||
end
|
||||
super(values)
|
||||
end
|
||||
|
|
|
@ -53,7 +53,7 @@ class LookupContextTest < ActiveSupport::TestCase
|
|||
|
||||
test "handles explicitly defined */* formats fallback to :js" do
|
||||
@lookup_context.formats = [:js, Mime::ALL]
|
||||
assert_equal [:js, :html], @lookup_context.formats
|
||||
assert_equal [:js, *Mime::SET.symbols], @lookup_context.formats
|
||||
end
|
||||
|
||||
test "adds :html fallback to :js formats" do
|
||||
|
|
Loading…
Reference in New Issue