diff options
author | Xavier Noria <fxn@hashref.com> | 2016-08-06 18:54:50 +0200 |
---|---|---|
committer | Xavier Noria <fxn@hashref.com> | 2016-08-06 18:54:50 +0200 |
commit | 35b3de8021e68649cac963bd82a74cc75d1f60f0 (patch) | |
tree | d37f9096be6ee54a13d3c04cc8e1c5a9ba0d99ec /actionpack/test/dispatch/request | |
parent | 628e51ff109334223094e30ad1365188bbd7f9c6 (diff) | |
download | rails-35b3de8021e68649cac963bd82a74cc75d1f60f0.tar.gz rails-35b3de8021e68649cac963bd82a74cc75d1f60f0.tar.bz2 rails-35b3de8021e68649cac963bd82a74cc75d1f60f0.zip |
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.
Diffstat (limited to 'actionpack/test/dispatch/request')
5 files changed, 124 insertions, 124 deletions
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 diff --git a/actionpack/test/dispatch/request/multipart_params_parsing_test.rb b/actionpack/test/dispatch/request/multipart_params_parsing_test.rb index bab4413b2a..67cd9ab85d 100644 --- a/actionpack/test/dispatch/request/multipart_params_parsing_test.rb +++ b/actionpack/test/dispatch/request/multipart_params_parsing_test.rb @@ -1,4 +1,4 @@ -require 'abstract_unit' +require "abstract_unit" class MultipartParamsParsingTest < ActionDispatch::IntegrationTest class TestController < ActionController::Base @@ -21,136 +21,136 @@ class MultipartParamsParsingTest < ActionDispatch::IntegrationTest end end - FIXTURE_PATH = File.dirname(__FILE__) + '/../../fixtures/multipart' + FIXTURE_PATH = File.dirname(__FILE__) + "/../../fixtures/multipart" def teardown TestController.last_request_parameters = nil end test "parses single parameter" do - assert_equal({ 'foo' => 'bar' }, parse_multipart('single_parameter')) + assert_equal({ "foo" => "bar" }, parse_multipart("single_parameter")) end test "parses bracketed parameters" do - assert_equal({ 'foo' => { 'baz' => 'bar'}}, parse_multipart('bracketed_param')) + assert_equal({ "foo" => { "baz" => "bar"}}, parse_multipart("bracketed_param")) end test "parse single utf8 parameter" do - assert_equal({ 'Iñtërnâtiônàlizætiøn_name' => 'Iñtërnâtiônàlizætiøn_value'}, - parse_multipart('single_utf8_param'), "request.request_parameters") + assert_equal({ "Iñtërnâtiônàlizætiøn_name" => "Iñtërnâtiônàlizætiøn_value"}, + parse_multipart("single_utf8_param"), "request.request_parameters") assert_equal( - 'Iñtërnâtiônàlizætiøn_value', - TestController.last_parameters['Iñtërnâtiônàlizætiøn_name'], "request.parameters") + "Iñtërnâtiônàlizætiøn_value", + TestController.last_parameters["Iñtërnâtiônàlizætiøn_name"], "request.parameters") end test "parse bracketed utf8 parameter" do - assert_equal({ 'Iñtërnâtiônàlizætiøn_name' => { - 'Iñtërnâtiônàlizætiøn_nested_name' => 'Iñtërnâtiônàlizætiøn_value'} }, - parse_multipart('bracketed_utf8_param'), "request.request_parameters") + assert_equal({ "Iñtërnâtiônàlizætiøn_name" => { + "Iñtërnâtiônàlizætiøn_nested_name" => "Iñtërnâtiônàlizætiøn_value"} }, + parse_multipart("bracketed_utf8_param"), "request.request_parameters") assert_equal( - {'Iñtërnâtiônàlizætiøn_nested_name' => 'Iñtërnâtiônàlizætiøn_value'}, - TestController.last_parameters['Iñtërnâtiônàlizætiøn_name'], "request.parameters") + {"Iñtërnâtiônàlizætiøn_nested_name" => "Iñtërnâtiônàlizætiøn_value"}, + TestController.last_parameters["Iñtërnâtiônàlizætiøn_name"], "request.parameters") end test "parses text file" do - params = parse_multipart('text_file') + params = parse_multipart("text_file") assert_equal %w(file foo), params.keys.sort - assert_equal 'bar', params['foo'] + assert_equal "bar", params["foo"] - file = params['file'] - assert_equal 'file.txt', file.original_filename + file = params["file"] + assert_equal "file.txt", file.original_filename assert_equal "text/plain", file.content_type - assert_equal 'contents', file.read + assert_equal "contents", file.read end test "parses utf8 filename with percent character" do - params = parse_multipart('utf8_filename') + params = parse_multipart("utf8_filename") assert_equal %w(file foo), params.keys.sort - assert_equal 'bar', params['foo'] + assert_equal "bar", params["foo"] - file = params['file'] - assert_equal 'ファイル%名.txt', file.original_filename + file = params["file"] + assert_equal "ファイル%名.txt", file.original_filename assert_equal "text/plain", file.content_type - assert_equal 'contents', file.read + assert_equal "contents", file.read end test "parses boundary problem file" do - params = parse_multipart('boundary_problem_file') + params = parse_multipart("boundary_problem_file") assert_equal %w(file foo), params.keys.sort - file = params['file'] - foo = params['foo'] + file = params["file"] + foo = params["foo"] - assert_equal 'file.txt', file.original_filename + assert_equal "file.txt", file.original_filename assert_equal "text/plain", file.content_type - assert_equal 'bar', foo + assert_equal "bar", foo end test "parses large text file" do - params = parse_multipart('large_text_file') + params = parse_multipart("large_text_file") assert_equal %w(file foo), params.keys.sort - assert_equal 'bar', params['foo'] + assert_equal "bar", params["foo"] - file = params['file'] + file = params["file"] - assert_equal 'file.txt', file.original_filename + assert_equal "file.txt", file.original_filename assert_equal "text/plain", file.content_type - assert_equal(('a' * 20480), file.read) + assert_equal(("a" * 20480), file.read) end test "parses binary file" do - params = parse_multipart('binary_file') + params = parse_multipart("binary_file") assert_equal %w(file flowers foo), params.keys.sort - assert_equal 'bar', params['foo'] + assert_equal "bar", params["foo"] - file = params['file'] - assert_equal 'file.csv', file.original_filename + file = params["file"] + assert_equal "file.csv", file.original_filename assert_nil file.content_type - assert_equal 'contents', file.read + assert_equal "contents", file.read - file = params['flowers'] - assert_equal 'flowers.jpg', file.original_filename + file = params["flowers"] + assert_equal "flowers.jpg", file.original_filename assert_equal "image/jpeg", file.content_type assert_equal 19512, file.size end test "parses mixed files" do - params = parse_multipart('mixed_files') + params = parse_multipart("mixed_files") assert_equal %w(files foo), params.keys.sort - assert_equal 'bar', params['foo'] + assert_equal "bar", params["foo"] # Rack doesn't handle multipart/mixed for us. - files = params['files'] + files = params["files"] assert_equal 19756, files.bytesize end test "does not create tempfile if no file has been selected" do - params = parse_multipart('none') + params = parse_multipart("none") assert_equal %w(submit-name), params.keys.sort - assert_equal 'Larry', params['submit-name'] - assert_equal nil, params['files'] + assert_equal "Larry", params["submit-name"] + assert_equal nil, params["files"] end test "parses empty upload file" do - params = parse_multipart('empty') + params = parse_multipart("empty") assert_equal %w(files submit-name), params.keys.sort - assert_equal 'Larry', params['submit-name'] - assert params['files'] - assert_equal "", params['files'].read + assert_equal "Larry", params["submit-name"] + assert params["files"] + assert_equal "", params["files"].read end test "uploads and reads binary file" do with_test_routing do fixture = FIXTURE_PATH + "/mona_lisa.jpg" params = { :uploaded_data => fixture_file_upload(fixture, "image/jpg") } - post '/read', params: params + post "/read", params: params end end test "uploads and reads file" do with_test_routing do - post '/read', params: { uploaded_data: fixture_file_upload(FIXTURE_PATH + "/hello.txt", "text/plain") } + post "/read", params: { uploaded_data: fixture_file_upload(FIXTURE_PATH + "/hello.txt", "text/plain") } assert_equal "File: Hello", response.body end end @@ -160,7 +160,7 @@ class MultipartParamsParsingTest < ActionDispatch::IntegrationTest with_routing do |set| set.draw do ActiveSupport::Deprecation.silence do - get ':action', controller: 'multipart_params_parsing_test/test' + get ":action", controller: "multipart_params_parsing_test/test" end end headers = { "CONTENT_TYPE" => "multipart/form-data; boundary=AaB03x" } @@ -171,7 +171,7 @@ class MultipartParamsParsingTest < ActionDispatch::IntegrationTest private def fixture(name) - File.open(File.join(FIXTURE_PATH, name), 'rb') do |file| + File.open(File.join(FIXTURE_PATH, name), "rb") do |file| { "rack.input" => file.read, "CONTENT_TYPE" => "multipart/form-data; boundary=AaB03x", "CONTENT_LENGTH" => file.stat.size.to_s } @@ -191,7 +191,7 @@ class MultipartParamsParsingTest < ActionDispatch::IntegrationTest with_routing do |set| set.draw do ActiveSupport::Deprecation.silence do - post ':action', :controller => 'multipart_params_parsing_test/test' + post ":action", :controller => "multipart_params_parsing_test/test" end end yield diff --git a/actionpack/test/dispatch/request/query_string_parsing_test.rb b/actionpack/test/dispatch/request/query_string_parsing_test.rb index f04022a544..4f8d4ccd34 100644 --- a/actionpack/test/dispatch/request/query_string_parsing_test.rb +++ b/actionpack/test/dispatch/request/query_string_parsing_test.rb @@ -1,4 +1,4 @@ -require 'abstract_unit' +require "abstract_unit" class QueryStringParsingTest < ActionDispatch::IntegrationTest class TestController < ActionController::Base @@ -36,36 +36,36 @@ class QueryStringParsingTest < ActionDispatch::IntegrationTest test "deep query string" do assert_parses( - {'x' => {'y' => {'z' => '10'}}}, + {"x" => {"y" => {"z" => "10"}}}, "x[y][z]=10" ) end test "deep query string with array" do - assert_parses({'x' => {'y' => {'z' => ['10']}}}, 'x[y][z][]=10') - assert_parses({'x' => {'y' => {'z' => ['10', '5']}}}, 'x[y][z][]=10&x[y][z][]=5') + assert_parses({"x" => {"y" => {"z" => ["10"]}}}, "x[y][z][]=10") + assert_parses({"x" => {"y" => {"z" => ["10", "5"]}}}, "x[y][z][]=10&x[y][z][]=5") end test "deep query string with array of hash" do - assert_parses({'x' => {'y' => [{'z' => '10'}]}}, 'x[y][][z]=10') - assert_parses({'x' => {'y' => [{'z' => '10', 'w' => '10'}]}}, 'x[y][][z]=10&x[y][][w]=10') - assert_parses({'x' => {'y' => [{'z' => '10', 'v' => {'w' => '10'}}]}}, 'x[y][][z]=10&x[y][][v][w]=10') + assert_parses({"x" => {"y" => [{"z" => "10"}]}}, "x[y][][z]=10") + assert_parses({"x" => {"y" => [{"z" => "10", "w" => "10"}]}}, "x[y][][z]=10&x[y][][w]=10") + assert_parses({"x" => {"y" => [{"z" => "10", "v" => {"w" => "10"}}]}}, "x[y][][z]=10&x[y][][v][w]=10") end test "deep query string with array of hashes with one pair" do - assert_parses({'x' => {'y' => [{'z' => '10'}, {'z' => '20'}]}}, 'x[y][][z]=10&x[y][][z]=20') + assert_parses({"x" => {"y" => [{"z" => "10"}, {"z" => "20"}]}}, "x[y][][z]=10&x[y][][z]=20") end test "deep query string with array of hashes with multiple pairs" do assert_parses( - {'x' => {'y' => [{'z' => '10', 'w' => 'a'}, {'z' => '20', 'w' => 'b'}]}}, - 'x[y][][z]=10&x[y][][w]=a&x[y][][z]=20&x[y][][w]=b' + {"x" => {"y" => [{"z" => "10", "w" => "a"}, {"z" => "20", "w" => "b"}]}}, + "x[y][][z]=10&x[y][][w]=a&x[y][][z]=20&x[y][][w]=b" ) end test "query string with nil" do assert_parses( - { "action" => "create_customer", "full_name" => ''}, + { "action" => "create_customer", "full_name" => ""}, "action=create_customer&full_name=" ) end @@ -101,7 +101,7 @@ class QueryStringParsingTest < ActionDispatch::IntegrationTest end def test_array_parses_without_nil - assert_parses({"action" => ['1']}, "action[]=1&action[]") + assert_parses({"action" => ["1"]}, "action[]=1&action[]") end test "perform_deep_munge" do @@ -114,7 +114,7 @@ class QueryStringParsingTest < ActionDispatch::IntegrationTest assert_parses({"action" => {"foo" => {"bar" => [nil]}}}, "action[foo][bar][]") assert_parses({"action" => {"foo" => [nil]}}, "action[foo][]") assert_parses({"action" => {"foo" => [{"bar" => nil}]}}, "action[foo][][bar]") - assert_parses({"action" => ['1',nil]}, "action[]=1&action[]") + assert_parses({"action" => ["1",nil]}, "action[]=1&action[]") ensure ActionDispatch::Request::Utils.perform_deep_munge = old_perform_deep_munge end @@ -136,7 +136,7 @@ class QueryStringParsingTest < ActionDispatch::IntegrationTest test "unbalanced query string with array" do assert_parses( - {'location' => ["1", "2"], 'age_group' => ["2"]}, + {"location" => ["1", "2"], "age_group" => ["2"]}, "location[]=1&location[]=2&age_group[]=2" ) end @@ -145,7 +145,7 @@ class QueryStringParsingTest < ActionDispatch::IntegrationTest with_routing do |set| set.draw do ActiveSupport::Deprecation.silence do - get ':action', :to => ::QueryStringParsingTest::TestController + get ":action", :to => ::QueryStringParsingTest::TestController end end @@ -159,7 +159,7 @@ class QueryStringParsingTest < ActionDispatch::IntegrationTest with_routing do |set| set.draw do ActiveSupport::Deprecation.silence do - get ':action', :to => ::QueryStringParsingTest::TestController + get ":action", :to => ::QueryStringParsingTest::TestController end end @app = self.class.build_app(set) do |middleware| diff --git a/actionpack/test/dispatch/request/session_test.rb b/actionpack/test/dispatch/request/session_test.rb index e022e7e21e..2f0042df29 100644 --- a/actionpack/test/dispatch/request/session_test.rb +++ b/actionpack/test/dispatch/request/session_test.rb @@ -1,5 +1,5 @@ -require 'abstract_unit' -require 'action_dispatch/middleware/session/abstract_store' +require "abstract_unit" +require "action_dispatch/middleware/session/abstract_store" module ActionDispatch class Request @@ -17,18 +17,18 @@ module ActionDispatch def test_to_hash s = Session.create(store, req, {}) - s['foo'] = 'bar' - assert_equal 'bar', s['foo'] - assert_equal({'foo' => 'bar'}, s.to_hash) + s["foo"] = "bar" + assert_equal "bar", s["foo"] + assert_equal({"foo" => "bar"}, s.to_hash) end def test_create_merges_old s = Session.create(store, req, {}) - s['foo'] = 'bar' + s["foo"] = "bar" s1 = Session.create(store, req, {}) assert_not_equal s, s1 - assert_equal 'bar', s1['foo'] + assert_equal "bar", s1["foo"] end def test_find @@ -40,7 +40,7 @@ module ActionDispatch def test_destroy s = Session.create(store, req, {}) - s['rails'] = 'ftw' + s["rails"] = "ftw" s.destroy @@ -49,22 +49,22 @@ module ActionDispatch def test_keys s = Session.create(store, req, {}) - s['rails'] = 'ftw' - s['adequate'] = 'awesome' + s["rails"] = "ftw" + s["adequate"] = "awesome" assert_equal %w[rails adequate], s.keys end def test_values s = Session.create(store, req, {}) - s['rails'] = 'ftw' - s['adequate'] = 'awesome' + s["rails"] = "ftw" + s["adequate"] = "awesome" assert_equal %w[ftw awesome], s.values end def test_clear s = Session.create(store, req, {}) - s['rails'] = 'ftw' - s['adequate'] = 'awesome' + s["rails"] = "ftw" + s["adequate"] = "awesome" s.clear assert_empty(s.values) @@ -72,19 +72,19 @@ module ActionDispatch def test_update s = Session.create(store, req, {}) - s['rails'] = 'ftw' + s["rails"] = "ftw" - s.update(:rails => 'awesome') + s.update(:rails => "awesome") - assert_equal(['rails'], s.keys) - assert_equal('awesome', s['rails']) + assert_equal(["rails"], s.keys) + assert_equal("awesome", s["rails"]) end def test_delete s = Session.create(store, req, {}) - s['rails'] = 'ftw' + s["rails"] = "ftw" - s.delete('rails') + s.delete("rails") assert_empty(s.keys) end @@ -92,13 +92,13 @@ module ActionDispatch def test_fetch session = Session.create(store, req, {}) - session['one'] = '1' - assert_equal '1', session.fetch(:one) + session["one"] = "1" + assert_equal "1", session.fetch(:one) - assert_equal '2', session.fetch(:two, '2') + assert_equal "2", session.fetch(:two, "2") assert_nil session.fetch(:two, nil) - assert_equal 'three', session.fetch(:three) {|el| el.to_s } + assert_equal "three", session.fetch(:three) {|el| el.to_s } assert_raise KeyError do session.fetch(:three) @@ -119,14 +119,14 @@ module ActionDispatch class MySessionApp def call(env) request = Rack::Request.new(env) - request.session['hello'] = 'Hello from MySessionApp!' - [ 200, {}, ['Hello from MySessionApp!'] ] + request.session["hello"] = "Hello from MySessionApp!" + [ 200, {}, ["Hello from MySessionApp!"] ] end end Router = ActionDispatch::Routing::RouteSet.new Router.draw do - get '/mysessionapp' => MySessionApp.new + get "/mysessionapp" => MySessionApp.new end def app @@ -134,10 +134,10 @@ module ActionDispatch end def test_session_follows_rack_api_contract_1 - get '/mysessionapp' + get "/mysessionapp" assert_response :ok - assert_equal 'Hello from MySessionApp!', @response.body - assert_equal 'Hello from MySessionApp!', session['hello'] + assert_equal "Hello from MySessionApp!", @response.body + assert_equal "Hello from MySessionApp!", session["hello"] end end end diff --git a/actionpack/test/dispatch/request/url_encoded_params_parsing_test.rb b/actionpack/test/dispatch/request/url_encoded_params_parsing_test.rb index b9f8c52378..5c7558e48d 100644 --- a/actionpack/test/dispatch/request/url_encoded_params_parsing_test.rb +++ b/actionpack/test/dispatch/request/url_encoded_params_parsing_test.rb @@ -1,4 +1,4 @@ -require 'abstract_unit' +require "abstract_unit" class UrlEncodedParamsParsingTest < ActionDispatch::IntegrationTest class TestController < ActionController::Base @@ -18,7 +18,7 @@ class UrlEncodedParamsParsingTest < ActionDispatch::IntegrationTest test "parses unbalanced query string with array" do query = "location[]=1&location[]=2&age_group[]=2" - expected = { 'location' => ["1", "2"], 'age_group' => ["2"] } + expected = { "location" => ["1", "2"], "age_group" => ["2"] } assert_parses expected, query end @@ -141,7 +141,7 @@ class UrlEncodedParamsParsingTest < ActionDispatch::IntegrationTest with_routing do |set| set.draw do ActiveSupport::Deprecation.silence do - post ':action', to: ::UrlEncodedParamsParsingTest::TestController + post ":action", to: ::UrlEncodedParamsParsingTest::TestController end end yield |