Permalink
Browse files

Ensure mime types can be compared with symbols. Closes #10796 [bscofi…

…eld]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8677 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent 88bc014 commit 250a1194b91e6ddb3e2e80d48753a1591992164b @NZKoz NZKoz committed Jan 20, 2008
Showing with 9 additions and 1 deletion.
  1. +4 −1 actionpack/lib/action_controller/mime_type.rb
  2. +5 −0 actionpack/test/controller/mime_type_test.rb
@@ -145,7 +145,10 @@ def ===(list)
end
def ==(mime_type)
- (@synonyms + [ self ]).any? { |synonym| synonym.to_s == mime_type.to_s } if mime_type
+ return false unless mime_type
+ (@synonyms + [ self ]).any? do |synonym|
+ synonym.to_s == mime_type.to_s || synonym.to_sym == mime_type.to_sym
+ end
end
private
@@ -39,6 +39,11 @@ def test_custom_type
Mime.module_eval { remove_const :GIF if const_defined?(:GIF) }
end
+ def test_type_should_be_equal_to_symbol
+ assert_equal Mime::HTML, 'application/xhtml+xml'
+ assert_equal Mime::HTML, :html
+ end
+
def test_type_convenience_methods
types = [:html, :xml, :png, :pdf, :yaml, :url_encoded_form]
types.each do |type|

0 comments on commit 250a119

Please sign in to comment.