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

Changeset 8829

Show
Ignore:
Timestamp:
02/10/08 01:03:27 (5 months ago)
Author:
nzkoz
Message:

2-0-stable: Ensure mime types can be compared with symbols. References #10796 [bscofield]

Merging [8677]

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/2-0-stable/actionpack/lib/action_controller/mime_type.rb

    r8001 r8829  
    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     
  • branches/2-0-stable/actionpack/test/controller/mime_type_test.rb

    r7719 r8829  
    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]