Permalink
Browse files

2-0-stable: Ensure mime types can be compared with symbols. References

…#10796 [bscofield]

Merging [8677]


git-svn-id: http://svn-commit.rubyonrails.org/rails/branches/2-0-stable@8829 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent 68477ad commit 81991d69132b37405b9dc797f2cfb7bad1f1792e @NZKoz NZKoz committed Feb 10, 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 81991d6

Please sign in to comment.