1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Ensure mime types can be compared with symbols. Closes #10796 [bscofield]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8677 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
Michael Koziarski 2008-01-20 22:55:25 +00:00
parent 88bc014acc
commit 250a1194b9
2 changed files with 9 additions and 1 deletions

View file

@ -145,7 +145,10 @@ module Mime
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

View file

@ -39,6 +39,11 @@ class MimeTypeTest < Test::Unit::TestCase
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|