diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2012-06-11 10:37:02 -0700 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2012-06-11 10:37:02 -0700 |
commit | 0e97aa2e51f810944162faaae2436313c248f8e8 (patch) | |
tree | 639ffffed6d95316e6428515117a1c1876f9c0b4 /actionpack | |
parent | 5304ae1269266ade678b0a387f9787e3d6b3d477 (diff) | |
parent | c74662a27f642700d3e59482bef6e6bc7e84b5ba (diff) | |
download | rails-0e97aa2e51f810944162faaae2436313c248f8e8.tar.gz rails-0e97aa2e51f810944162faaae2436313c248f8e8.tar.bz2 rails-0e97aa2e51f810944162faaae2436313c248f8e8.zip |
Merge pull request #6705 from ganeshkumar/string_method_changes
both string and symbol will be interpolated as string no need to convert to_s
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/lib/action_dispatch/http/mime_type.rb | 6 | ||||
-rw-r--r-- | actionpack/test/dispatch/mime_type_test.rb | 10 |
2 files changed, 8 insertions, 8 deletions
diff --git a/actionpack/lib/action_dispatch/http/mime_type.rb b/actionpack/lib/action_dispatch/http/mime_type.rb index 0eaae80461..ee1913dbf9 100644 --- a/actionpack/lib/action_dispatch/http/mime_type.rb +++ b/actionpack/lib/action_dispatch/http/mime_type.rb @@ -99,9 +99,9 @@ module Mime end def register(string, symbol, mime_type_synonyms = [], extension_synonyms = [], skip_lookup = false) - Mime.const_set(symbol.to_s.upcase, Type.new(string, symbol, mime_type_synonyms)) + Mime.const_set(symbol.upcase, Type.new(string, symbol, mime_type_synonyms)) - SET << Mime.const_get(symbol.to_s.upcase) + SET << Mime.const_get(symbol.upcase) ([string] + mime_type_synonyms).each { |str| LOOKUP[str] = SET.last } unless skip_lookup ([symbol] + extension_synonyms).each { |ext| EXTENSION_LOOKUP[ext.to_s] = SET.last } @@ -194,7 +194,7 @@ module Mime # # Mime::Type.unregister(:mobile) def unregister(symbol) - symbol = symbol.to_s.upcase + symbol = symbol.upcase mime = Mime.const_get(symbol) Mime.instance_eval { remove_const(symbol) } diff --git a/actionpack/test/dispatch/mime_type_test.rb b/actionpack/test/dispatch/mime_type_test.rb index e3f9faaa64..9d77c3acc5 100644 --- a/actionpack/test/dispatch/mime_type_test.rb +++ b/actionpack/test/dispatch/mime_type_test.rb @@ -148,11 +148,11 @@ class MimeTypeTest < ActiveSupport::TestCase types = Mime::SET.symbols.uniq - [:all, :iphone] # Remove custom Mime::Type instances set in other tests, like Mime::GIF and Mime::IPHONE - types.delete_if { |type| !Mime.const_defined?(type.to_s.upcase) } + types.delete_if { |type| !Mime.const_defined?(type.upcase) } types.each do |type| - mime = Mime.const_get(type.to_s.upcase) + mime = Mime.const_get(type.upcase) assert mime.respond_to?("#{type}?"), "#{mime.inspect} does not respond to #{type}?" assert mime.send("#{type}?"), "#{mime.inspect} is not #{type}?" invalid_types = types - [type] @@ -170,10 +170,10 @@ class MimeTypeTest < ActiveSupport::TestCase all_types = Mime::SET.symbols all_types.uniq! # Remove custom Mime::Type instances set in other tests, like Mime::GIF and Mime::IPHONE - all_types.delete_if { |type| !Mime.const_defined?(type.to_s.upcase) } + all_types.delete_if { |type| !Mime.const_defined?(type.upcase) } verified, unverified = all_types.partition { |type| Mime::Type.browser_generated_types.include? type } - assert verified.each { |type| assert Mime.const_get(type.to_s.upcase).verify_request?, "Verifiable Mime Type is not verified: #{type.inspect}" } - assert unverified.each { |type| assert !Mime.const_get(type.to_s.upcase).verify_request?, "Nonverifiable Mime Type is verified: #{type.inspect}" } + assert verified.each { |type| assert Mime.const_get(type.upcase).verify_request?, "Verifiable Mime Type is not verified: #{type.inspect}" } + assert unverified.each { |type| assert !Mime.const_get(type.upcase).verify_request?, "Nonverifiable Mime Type is verified: #{type.inspect}" } end test "references gives preference to symbols before strings" do |