Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 8677

Show
Ignore:
Timestamp:
01/20/08 22:55:25 (8 months ago)
Author:
nzkoz
Message:

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

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/actionpack/lib/action_controller/mime_type.rb

    r8001 r8677  
    146146     
    147147    def ==(mime_type) 
    148       (@synonyms + [ self ]).any? { |synonym| synonym.to_s == mime_type.to_s } if mime_type 
     148      return false unless mime_type 
     149      (@synonyms + [ self ]).any? do |synonym|  
     150        synonym.to_s == mime_type.to_s || synonym.to_sym == mime_type.to_sym  
     151      end 
    149152    end 
    150153     
  • trunk/actionpack/test/controller/mime_type_test.rb

    r8564 r8677  
    4040  end 
    4141   
     42  def test_type_should_be_equal_to_symbol 
     43    assert_equal Mime::HTML, 'application/xhtml+xml' 
     44    assert_equal Mime::HTML, :html 
     45  end 
     46 
    4247  def test_type_convenience_methods 
    4348    types = [:html, :xml, :png, :pdf, :yaml, :url_encoded_form]