提交 250a1194 编写于 作者: M Michael Koziarski

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
上级 88bc014a
......@@ -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|
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册