From cdbbf6fd6bef3f286503859c585ada8fe66a3875 Mon Sep 17 00:00:00 2001 From: Neeraj Singh Date: Mon, 22 Nov 2010 11:51:43 -0500 Subject: move the mime registration code to setup so that it could be cleaned up on teardown. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- actionpack/test/controller/mime_responds_test.rb | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'actionpack') diff --git a/actionpack/test/controller/mime_responds_test.rb b/actionpack/test/controller/mime_responds_test.rb index 7a799411db..0da051822a 100644 --- a/actionpack/test/controller/mime_responds_test.rb +++ b/actionpack/test/controller/mime_responds_test.rb @@ -97,7 +97,6 @@ class RespondToController < ActionController::Base end end - Mime::Type.register("text/x-mobile", :mobile) def custom_constant_handling respond_to do |type| @@ -134,7 +133,6 @@ class RespondToController < ActionController::Base 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 @@ class RespondWithControllerTest < ActionController::TestCase 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 -- cgit v1.2.3