diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2016-02-22 17:37:53 -0300 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2016-02-22 21:22:29 -0300 |
commit | 4f30df4b524b5da22491090e22f5c2de789dd016 (patch) | |
tree | 2151c15da92c50c8d4ef5df08c7805b3e33ca0cb /actionpack | |
parent | a087cf4312c1ec01f3bb021a6791ac3a6ef1cec3 (diff) | |
download | rails-4f30df4b524b5da22491090e22f5c2de789dd016.tar.gz rails-4f30df4b524b5da22491090e22f5c2de789dd016.tar.bz2 rails-4f30df4b524b5da22491090e22f5c2de789dd016.zip |
Make sure we unregister the mime type before registering
Also make sure we don't change the global state of our test suite.
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/test/dispatch/request/json_params_parsing_test.rb | 32 |
1 files changed, 22 insertions, 10 deletions
diff --git a/actionpack/test/dispatch/request/json_params_parsing_test.rb b/actionpack/test/dispatch/request/json_params_parsing_test.rb index 0c3c6d5f93..3655c7f570 100644 --- a/actionpack/test/dispatch/request/json_params_parsing_test.rb +++ b/actionpack/test/dispatch/request/json_params_parsing_test.rb @@ -151,19 +151,31 @@ class RootLessJSONParamsParsingTest < ActionDispatch::IntegrationTest end test "parses json params after custom json mime type registered" do - Mime::Type.register "application/json", :json, %w(application/vnd.api+json) - assert_parses( - {"user" => {"username" => "meinac"}, "username" => "meinac"}, - "{\"username\": \"meinac\"}", { 'CONTENT_TYPE' => 'application/json' } - ) + begin + Mime::Type.unregister :json + Mime::Type.register "application/json", :json, %w(application/vnd.api+json) + assert_parses( + {"user" => {"username" => "meinac"}, "username" => "meinac"}, + "{\"username\": \"meinac\"}", { 'CONTENT_TYPE' => 'application/json' } + ) + ensure + Mime::Type.unregister :json + Mime::Type.register "application/json", :json, %w( text/x-json application/jsonrequest ) + end end test "parses json params after custom json mime type registered with synonym" do - Mime::Type.register "application/json", :json, %w(application/vnd.api+json) - assert_parses( - {"user" => {"username" => "meinac"}, "username" => "meinac"}, - "{\"username\": \"meinac\"}", { 'CONTENT_TYPE' => 'application/vnd.api+json' } - ) + begin + Mime::Type.unregister :json + Mime::Type.register "application/json", :json, %w(application/vnd.api+json) + assert_parses( + {"user" => {"username" => "meinac"}, "username" => "meinac"}, + "{\"username\": \"meinac\"}", { 'CONTENT_TYPE' => 'application/vnd.api+json' } + ) + ensure + Mime::Type.unregister :json + Mime::Type.register "application/json", :json, %w( text/x-json application/jsonrequest ) + end end private |