diff options
author | Neeraj Singh <neerajdotname@gmail.com> | 2010-11-22 11:51:43 -0500 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2010-11-22 23:06:14 +0100 |
commit | cdbbf6fd6bef3f286503859c585ada8fe66a3875 (patch) | |
tree | e7f22c6415d253bb809de9f2550e8bf28ac8ec66 | |
parent | 23ea19e20d6f7df762635b1c6d83369922d5ad7b (diff) | |
download | rails-cdbbf6fd6bef3f286503859c585ada8fe66a3875.tar.gz rails-cdbbf6fd6bef3f286503859c585ada8fe66a3875.tar.bz2 rails-cdbbf6fd6bef3f286503859c585ada8fe66a3875.zip |
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>
-rw-r--r-- | actionpack/test/controller/mime_responds_test.rb | 21 |
1 files changed, 19 insertions, 2 deletions
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 |