Browse files

move the mime registration code to setup so that

it could be cleaned up on teardown.

Currently the test code
test/controller/mime_responds_test.rb impacts
test/dispatch/mime_type_test.rb.

dispatch/mime_type_test.rb runs independently fine
but when run as part of rake breaks because of
new mime types registered in
controller/mime_responds_test.rb

Signed-off-by: José Valim <jose.valim@gmail.com>
  • Loading branch information...
1 parent 23ea19e commit cdbbf6fd6bef3f286503859c585ada8fe66a3875 Neeraj Singh committed with josevalim Nov 22, 2010
Showing with 19 additions and 2 deletions.
  1. +19 −2 actionpack/test/controller/mime_responds_test.rb
View
21 actionpack/test/controller/mime_responds_test.rb
@@ -97,7 +97,6 @@ def custom_type_handling
end
end
- Mime::Type.register("text/x-mobile", :mobile)
def custom_constant_handling
respond_to do |type|
@@ -134,7 +133,6 @@ def all_types_with_layout
end
end
- Mime::Type.register_alias("text/html", :iphone)
def iphone_with_html_response_type
request.format = :iphone if request.env["HTTP_ACCEPT"] == "text/iphone"
@@ -200,10 +198,16 @@ class RespondToControllerTest < 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.module_eval { remove_const :IPHONE if const_defined?(:IPHONE) }
+ Mime.module_eval { remove_const :MOBILE if const_defined?(:MOBILE) }
+ Mime::LOOKUP.reject!{|key,_| key == 'text/x-mobile'}
+ Mime::LOOKUP.reject!{|key,_| key == 'text/iphone'}
end
def test_html
@@ -616,6 +620,10 @@ def setup
def teardown
super
+ Mime.module_eval { remove_const :IPHONE if const_defined?(:IPHONE) }
+ Mime.module_eval { remove_const :MOBILE if const_defined?(:MOBILE) }
+ Mime::LOOKUP.reject!{|key,_| key == 'text/x-mobile'}
+ Mime::LOOKUP.reject!{|key,_| key == 'text/iphone'}
end
def test_using_resource
@@ -996,6 +1004,15 @@ class MimeControllerLayoutsTest < ActionController::TestCase
def setup
super
@request.host = "www.example.com"
+ Mime::Type.register_alias("text/html", :iphone)
+ end
+
+ def teardown
+ super
+ Mime.module_eval { remove_const :IPHONE if const_defined?(:IPHONE) }
+ Mime.module_eval { remove_const :MOBILE if const_defined?(:MOBILE) }
+ Mime::LOOKUP.reject!{|key,_| key == 'text/x-mobile'}
+ Mime::LOOKUP.reject!{|key,_| key == 'text/iphone'}
end
def test_missing_layout_renders_properly

0 comments on commit cdbbf6f

Please sign in to comment.