Skip to content

Commit

Permalink
Always expand */*
Browse files Browse the repository at this point in the history
  • Loading branch information
josevalim committed May 7, 2011
1 parent fadd1fa commit 0a1ba4e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
11 changes: 4 additions & 7 deletions actionpack/lib/action_view/lookup_context.rb
Expand Up @@ -167,15 +167,12 @@ def freeze_formats(formats, unless_frozen=false) #:nodoc:
@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
Expand Down
2 changes: 1 addition & 1 deletion actionpack/test/template/lookup_context_test.rb
Expand Up @@ -53,7 +53,7 @@ def teardown

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
Expand Down

0 comments on commit 0a1ba4e

Please sign in to comment.