aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/dispatch
diff options
context:
space:
mode:
authorNeeraj Singh <neerajdotname@gmail.com>2010-11-23 23:28:57 +0800
committerJosé Valim <jose.valim@gmail.com>2010-11-25 04:38:47 +0800
commite8708836252852d8bae87c80472b865812fa9776 (patch)
tree0ea7dd6319d9a9d284533d1c01776a9ba968be31 /actionpack/test/dispatch
parentc6030e8562cddcb71898a1dea242affe5f0464f0 (diff)
downloadrails-e8708836252852d8bae87c80472b865812fa9776.tar.gz
rails-e8708836252852d8bae87c80472b865812fa9776.tar.bz2
rails-e8708836252852d8bae87c80472b865812fa9776.zip
unregister method implementation and test
Diffstat (limited to 'actionpack/test/dispatch')
-rw-r--r--actionpack/test/dispatch/mime_type_test.rb17
1 files changed, 17 insertions, 0 deletions
diff --git a/actionpack/test/dispatch/mime_type_test.rb b/actionpack/test/dispatch/mime_type_test.rb
index 43123e68b2..f2d2799a67 100644
--- a/actionpack/test/dispatch/mime_type_test.rb
+++ b/actionpack/test/dispatch/mime_type_test.rb
@@ -12,6 +12,23 @@ class MimeTypeTest < ActiveSupport::TestCase
end
end
+ test "unregister" do
+ begin
+ Mime::Type.register("text/x-mobile", :mobile)
+ assert defined?(Mime::MOBILE)
+ assert_equal Mime::MOBILE, Mime::LOOKUP['text/x-mobile']
+ assert_equal Mime::MOBILE, Mime::EXTENSION_LOOKUP['mobile']
+
+ Mime::Type.unregister("text/x-mobile", :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]"
+ ensure
+ Mime.module_eval { remove_const :MOBILE if const_defined?(:MOBILE) }
+ Mime::LOOKUP.reject!{|key,_| key == 'text/x-mobile'}
+ end
+ end
+
test "parse text with trailing star" do
accept = "text/*"
expect = [Mime::JSON, Mime::XML, Mime::ICS, Mime::HTML, Mime::CSS, Mime::CSV, Mime::JS, Mime::YAML, Mime::TEXT].sort_by(&:to_s)