mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04: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:
@@ -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
|
||||
|
||||
@@ -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|
|
||||
|
||||
Reference in New Issue
Block a user