Permalink
Browse files

Always expand */*

  • Loading branch information...
1 parent fadd1fa commit 0a1ba4eab0c442f3e9f4027e4b5d3418f8eb6ca4 @josevalim josevalim committed May 7, 2011
Showing with 5 additions and 8 deletions.
  1. +4 −7 actionpack/lib/action_view/lookup_context.rb
  2. +1 −1 actionpack/test/template/lookup_context_test.rb
@@ -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
@@ -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

0 comments on commit 0a1ba4e

Please sign in to comment.