From 35b3de8021e68649cac963bd82a74cc75d1f60f0 Mon Sep 17 00:00:00 2001 From: Xavier Noria Date: Sat, 6 Aug 2016 18:54:50 +0200 Subject: applies new string literal convention in actionpack/test The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default. --- .../dispatch/request/json_params_parsing_test.rb | 40 +++++++++++----------- 1 file changed, 20 insertions(+), 20 deletions(-) (limited to 'actionpack/test/dispatch/request/json_params_parsing_test.rb') diff --git a/actionpack/test/dispatch/request/json_params_parsing_test.rb b/actionpack/test/dispatch/request/json_params_parsing_test.rb index 6ab71ebc81..039888b895 100644 --- a/actionpack/test/dispatch/request/json_params_parsing_test.rb +++ b/actionpack/test/dispatch/request/json_params_parsing_test.rb @@ -1,4 +1,4 @@ -require 'abstract_unit' +require "abstract_unit" class JsonParamsParsingTest < ActionDispatch::IntegrationTest class TestController < ActionController::Base @@ -19,43 +19,43 @@ class JsonParamsParsingTest < ActionDispatch::IntegrationTest test "parses json params for application json" do assert_parses( {"person" => {"name" => "David"}}, - "{\"person\": {\"name\": \"David\"}}", { 'CONTENT_TYPE' => 'application/json' } + "{\"person\": {\"name\": \"David\"}}", { "CONTENT_TYPE" => "application/json" } ) end test "parses boolean and number json params for application json" do assert_parses( {"item" => {"enabled" => false, "count" => 10}}, - "{\"item\": {\"enabled\": false, \"count\": 10}}", { 'CONTENT_TYPE' => 'application/json' } + "{\"item\": {\"enabled\": false, \"count\": 10}}", { "CONTENT_TYPE" => "application/json" } ) end test "parses json params for application jsonrequest" do assert_parses( {"person" => {"name" => "David"}}, - "{\"person\": {\"name\": \"David\"}}", { 'CONTENT_TYPE' => 'application/jsonrequest' } + "{\"person\": {\"name\": \"David\"}}", { "CONTENT_TYPE" => "application/jsonrequest" } ) end test "does not parse unregistered media types such as application/vnd.api+json" do assert_parses( {}, - "{\"person\": {\"name\": \"David\"}}", { 'CONTENT_TYPE' => 'application/vnd.api+json' } + "{\"person\": {\"name\": \"David\"}}", { "CONTENT_TYPE" => "application/vnd.api+json" } ) end test "nils are stripped from collections" do assert_parses( {"person" => []}, - "{\"person\":[null]}", { 'CONTENT_TYPE' => 'application/json' } + "{\"person\":[null]}", { "CONTENT_TYPE" => "application/json" } ) assert_parses( - {"person" => ['foo']}, - "{\"person\":[\"foo\",null]}", { 'CONTENT_TYPE' => 'application/json' } + {"person" => ["foo"]}, + "{\"person\":[\"foo\",null]}", { "CONTENT_TYPE" => "application/json" } ) assert_parses( {"person" => []}, - "{\"person\":[null, null]}", { 'CONTENT_TYPE' => 'application/json' } + "{\"person\":[null, null]}", { "CONTENT_TYPE" => "application/json" } ) end @@ -63,7 +63,7 @@ class JsonParamsParsingTest < ActionDispatch::IntegrationTest with_test_routing do output = StringIO.new json = "[\"person]\": {\"name\": \"David\"}}" - post "/parse", params: json, headers: { 'CONTENT_TYPE' => 'application/json', 'action_dispatch.show_exceptions' => true, 'action_dispatch.logger' => ActiveSupport::Logger.new(output) } + post "/parse", params: json, headers: { "CONTENT_TYPE" => "application/json", "action_dispatch.show_exceptions" => true, "action_dispatch.logger" => ActiveSupport::Logger.new(output) } assert_response :bad_request output.rewind && err = output.read assert err =~ /Error occurred while parsing request parameters/ @@ -75,7 +75,7 @@ class JsonParamsParsingTest < ActionDispatch::IntegrationTest begin $stderr = StringIO.new # suppress the log json = "[\"person]\": {\"name\": \"David\"}}" - exception = assert_raise(ActionDispatch::ParamsParser::ParseError) { post "/parse", json, {'CONTENT_TYPE' => 'application/json', 'action_dispatch.show_exceptions' => false} } + exception = assert_raise(ActionDispatch::ParamsParser::ParseError) { post "/parse", json, {"CONTENT_TYPE" => "application/json", "action_dispatch.show_exceptions" => false} } assert_equal JSON::ParserError, exception.cause.class assert_equal exception.cause.message, exception.message ensure @@ -84,9 +84,9 @@ class JsonParamsParsingTest < ActionDispatch::IntegrationTest end end - test 'raw_post is not empty for JSON request' do + test "raw_post is not empty for JSON request" do with_test_routing do - post '/parse', params: '{"posts": [{"title": "Post Title"}]}', headers: { 'CONTENT_TYPE' => 'application/json' } + post "/parse", params: '{"posts": [{"title": "Post Title"}]}', headers: { "CONTENT_TYPE" => "application/json" } assert_equal '{"posts": [{"title": "Post Title"}]}', request.raw_post end end @@ -104,7 +104,7 @@ class JsonParamsParsingTest < ActionDispatch::IntegrationTest with_routing do |set| set.draw do ActiveSupport::Deprecation.silence do - post ':action', :to => ::JsonParamsParsingTest::TestController + post ":action", :to => ::JsonParamsParsingTest::TestController end end yield @@ -134,21 +134,21 @@ class RootLessJSONParamsParsingTest < ActionDispatch::IntegrationTest test "parses json params for application json" do assert_parses( {"user" => {"username" => "sikachu"}, "username" => "sikachu"}, - "{\"username\": \"sikachu\"}", { 'CONTENT_TYPE' => 'application/json' } + "{\"username\": \"sikachu\"}", { "CONTENT_TYPE" => "application/json" } ) end test "parses json params for application jsonrequest" do assert_parses( {"user" => {"username" => "sikachu"}, "username" => "sikachu"}, - "{\"username\": \"sikachu\"}", { 'CONTENT_TYPE' => 'application/jsonrequest' } + "{\"username\": \"sikachu\"}", { "CONTENT_TYPE" => "application/jsonrequest" } ) end test "parses json with non-object JSON content" do assert_parses( {"user" => {"_json" => "string content" }, "_json" => "string content" }, - "\"string content\"", { 'CONTENT_TYPE' => 'application/json' } + "\"string content\"", { "CONTENT_TYPE" => "application/json" } ) end @@ -158,7 +158,7 @@ class RootLessJSONParamsParsingTest < ActionDispatch::IntegrationTest Mime::Type.register "application/json", :json, %w(application/vnd.rails+json) assert_parses( {"user" => {"username" => "meinac"}, "username" => "meinac"}, - "{\"username\": \"meinac\"}", { 'CONTENT_TYPE' => 'application/json' } + "{\"username\": \"meinac\"}", { "CONTENT_TYPE" => "application/json" } ) ensure Mime::Type.unregister :json @@ -172,7 +172,7 @@ class RootLessJSONParamsParsingTest < ActionDispatch::IntegrationTest Mime::Type.register "application/json", :json, %w(application/vnd.rails+json) assert_parses( {"user" => {"username" => "meinac"}, "username" => "meinac"}, - "{\"username\": \"meinac\"}", { 'CONTENT_TYPE' => 'application/vnd.rails+json' } + "{\"username\": \"meinac\"}", { "CONTENT_TYPE" => "application/vnd.rails+json" } ) ensure Mime::Type.unregister :json @@ -194,7 +194,7 @@ class RootLessJSONParamsParsingTest < ActionDispatch::IntegrationTest with_routing do |set| set.draw do ActiveSupport::Deprecation.silence do - post ':action', :to => controller + post ":action", :to => controller end end yield -- cgit v1.2.3