Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix tests on 1.9.2.

  • Loading branch information...
commit 31906eecdf7bffc2203379c5d40f1bb77fb35858 1 parent a4c360e
@josevalim josevalim authored
View
15 actionpack/lib/action_dispatch/http/mime_type.rb
@@ -190,12 +190,15 @@ def parse_data_with_trailing_star(input)
#
# Usage:
#
- # Mime::Type.unregister("text/x-mobile", :mobile)
- def unregister(string, symbol)
- EXTENSION_LOOKUP.delete(symbol.to_s)
- LOOKUP.delete(string)
- symbol = symbol.to_s.upcase.intern
- Mime.module_eval { remove_const(symbol) if const_defined?(symbol) }
+ # Mime::Type.unregister(:mobile)
+ def unregister(symbol)
+ symbol = symbol.to_s.upcase
+ mime = Mime.const_get(symbol)
+ Mime.instance_eval { remove_const(symbol) }
+
+ SET.delete_if { |v| v.eql?(mime) }
+ LOOKUP.delete_if { |k,v| v.eql?(mime) }
+ EXTENSION_LOOKUP.delete_if { |k,v| v.eql?(mime) }
end
end
View
16 actionpack/test/controller/mime_responds_test.rb
@@ -201,8 +201,8 @@ def setup
def teardown
super
- Mime::Type.unregister('text/x-mobile', :iphone)
- Mime::Type.unregister('text/iphone', :mobile)
+ Mime::Type.unregister(:iphone)
+ Mime::Type.unregister(:mobile)
end
def test_html
@@ -622,12 +622,14 @@ class RespondWithControllerTest < ActionController::TestCase
def setup
super
@request.host = "www.example.com"
+ Mime::Type.register_alias('text/html', :iphone)
+ Mime::Type.register('text/x-mobile', :mobile)
end
def teardown
super
- Mime::Type.unregister('text/x-mobile', :iphone)
- Mime::Type.unregister('text/iphone', :mobile)
+ Mime::Type.unregister(:iphone)
+ Mime::Type.unregister(:mobile)
end
def test_using_resource
@@ -929,7 +931,8 @@ def test_render_json_object_responds_to_str_still_produce_json
@controller = RenderJsonRespondWithController.new
@request.accept = "application/json"
get :index, :format => :json
- assert_equal %Q{{"message":"boom","error":"RenderJsonTestException"}}, @response.body
+ assert_match(/"message":"boom"/, @response.body)
+ assert_match(/"error":"RenderJsonTestException"/, @response.body)
end
def test_no_double_render_is_raised
@@ -1020,8 +1023,7 @@ def setup
def teardown
super
- Mime::Type.unregister('text/x-mobile', :iphone)
- Mime::Type.unregister('text/iphone', :mobile)
+ Mime::Type.unregister(:iphone)
end
def test_missing_layout_renders_properly
View
9 actionpack/test/dispatch/mime_type_test.rb
@@ -19,7 +19,7 @@ class MimeTypeTest < ActiveSupport::TestCase
assert_equal Mime::MOBILE, Mime::LOOKUP['text/x-mobile']
assert_equal Mime::MOBILE, Mime::EXTENSION_LOOKUP['mobile']
- Mime::Type.unregister("text/x-mobile", :mobile)
+ Mime::Type.unregister(:mobile)
assert !defined?(Mime::MOBILE), "Mime::MOBILE should not be defined"
assert !Mime::LOOKUP.has_key?('text/x-mobile'), "Mime::LOOKUP should not have key ['text/x-mobile]"
assert !Mime::EXTENSION_LOOKUP.has_key?('mobile'), "Mime::EXTENSION_LOOKUP should not have key ['mobile]"
@@ -52,10 +52,9 @@ class MimeTypeTest < ActiveSupport::TestCase
test "parse application with trailing star" do
accept = "application/*"
- expect = [Mime::HTML, Mime::JS, Mime::XML, Mime::YAML, Mime::ATOM, Mime::JSON, Mime::RSS, Mime::PDF, Mime::URL_ENCODED_FORM].sort_by(&:to_s)
+ expect = [Mime::HTML, Mime::JS, Mime::XML, Mime::RSS, Mime::ATOM, Mime::YAML, Mime::URL_ENCODED_FORM, Mime::JSON, Mime::PDF]
parsed = Mime::Type.parse(accept)
- assert_equal 9, parsed.size
- assert_equal expect, parsed.sort_by(&:to_s)
+ assert_equal expect, parsed
end
test "parse without q" do
@@ -92,7 +91,7 @@ class MimeTypeTest < ActiveSupport::TestCase
assert_equal Mime::GIF, Mime::SET.last
end
ensure
- Mime::Type.unregister('image/gif', :gif)
+ Mime::Type.unregister(:gif)
end
end
View
2  actionpack/test/lib/controller/fake_models.rb
@@ -197,6 +197,6 @@ def each
class RenderJsonTestException < Exception
def to_json(options = nil)
- return { :error => self.class.name, :message => self.to_str }.to_json
+ return { :error => self.class.name, :message => self.to_s }.to_json
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.