diff --git a/actionpack/lib/action_controller/mime_type.rb b/actionpack/lib/action_controller/mime_type.rb index ec9d2eea6d..16e3ffc9c1 100644 --- a/actionpack/lib/action_controller/mime_type.rb +++ b/actionpack/lib/action_controller/mime_type.rb @@ -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 diff --git a/actionpack/test/controller/mime_type_test.rb b/actionpack/test/controller/mime_type_test.rb index 5f29393fce..991ac04f62 100644 --- a/actionpack/test/controller/mime_type_test.rb +++ b/actionpack/test/controller/mime_type_test.rb @@ -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|