aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack/test')
-rw-r--r--actionpack/test/abstract/translation_test.rb6
-rw-r--r--actionpack/test/controller/flash_hash_test.rb6
-rw-r--r--actionpack/test/controller/live_stream_test.rb6
-rw-r--r--actionpack/test/controller/new_base/render_action_test.rb6
-rw-r--r--actionpack/test/controller/parameters/always_permitted_parameters_test.rb6
-rw-r--r--actionpack/test/controller/parameters/log_on_unpermitted_params_test.rb20
-rw-r--r--actionpack/test/controller/parameters/multi_parameter_attributes_test.rb6
-rw-r--r--actionpack/test/controller/parameters/nested_parameters_permit_test.rb60
-rw-r--r--actionpack/test/controller/parameters/parameters_permit_test.rb4
-rw-r--r--actionpack/test/controller/parameters/raise_on_unpermitted_params_test.rb10
-rw-r--r--actionpack/test/controller/params_wrapper_test.rb50
-rw-r--r--actionpack/test/controller/redirect_test.rb8
-rw-r--r--actionpack/test/controller/renderer_test.rb2
-rw-r--r--actionpack/test/controller/required_params_test.rb2
-rw-r--r--actionpack/test/controller/resources_test.rb4
-rw-r--r--actionpack/test/controller/routing_test.rb186
-rw-r--r--actionpack/test/controller/test_case_test.rb20
-rw-r--r--actionpack/test/controller/url_for_test.rb16
-rw-r--r--actionpack/test/controller/url_rewriter_test.rb6
-rw-r--r--actionpack/test/controller/webservice_test.rb2
-rw-r--r--actionpack/test/dispatch/callbacks_test.rb2
-rw-r--r--actionpack/test/dispatch/executor_test.rb2
-rw-r--r--actionpack/test/dispatch/rack_cache_test.rb2
-rw-r--r--actionpack/test/dispatch/reloader_test.rb2
-rw-r--r--actionpack/test/dispatch/request/json_params_parsing_test.rb28
-rw-r--r--actionpack/test/dispatch/response_test.rb4
-rw-r--r--actionpack/test/dispatch/routing_assertions_test.rb32
-rw-r--r--actionpack/test/journey/route_test.rb32
-rw-r--r--actionpack/test/journey/router_test.rb14
29 files changed, 247 insertions, 297 deletions
diff --git a/actionpack/test/abstract/translation_test.rb b/actionpack/test/abstract/translation_test.rb
index 4b807c2e04..1e17cb9777 100644
--- a/actionpack/test/abstract/translation_test.rb
+++ b/actionpack/test/abstract/translation_test.rb
@@ -9,8 +9,7 @@ module AbstractController
class TranslationControllerTest < ActiveSupport::TestCase
def setup
@controller = TranslationController.new
- I18n.backend.store_translations(:en, {
- one: {
+ I18n.backend.store_translations(:en, one: {
two: "bar",
},
abstract_controller: {
@@ -22,8 +21,7 @@ module AbstractController
no_action: "no_action_tr",
},
},
- },
- })
+ })
end
def test_action_controller_base_responds_to_translate
diff --git a/actionpack/test/controller/flash_hash_test.rb b/actionpack/test/controller/flash_hash_test.rb
index be2bcb5ce2..16651a3fd7 100644
--- a/actionpack/test/controller/flash_hash_test.rb
+++ b/actionpack/test/controller/flash_hash_test.rb
@@ -141,7 +141,7 @@ module ActionDispatch
def test_update_sweep
@hash["hello"] = "world"
- @hash.update({"hi" => "mom"})
+ @hash.update("hi" => "mom")
@hash.sweep
assert_equal({"hello" => "world", "hi" => "mom"}, @hash.to_hash)
@@ -150,7 +150,7 @@ module ActionDispatch
def test_update_delete_sweep
@hash["hello"] = "world"
@hash.delete "hello"
- @hash.update({"hello" => "mom"})
+ @hash.update("hello" => "mom")
@hash.sweep
assert_equal({"hello" => "mom"}, @hash.to_hash)
@@ -175,7 +175,7 @@ module ActionDispatch
def test_replace_sweep
@hash["hello"] = "world"
- @hash.replace({"hi" => "mom"})
+ @hash.replace("hi" => "mom")
@hash.sweep
assert_equal({"hi" => "mom"}, @hash.to_hash)
diff --git a/actionpack/test/controller/live_stream_test.rb b/actionpack/test/controller/live_stream_test.rb
index 6d0bc8244b..3ea02f0a19 100644
--- a/actionpack/test/controller/live_stream_test.rb
+++ b/actionpack/test/controller/live_stream_test.rb
@@ -11,7 +11,7 @@ module ActionController
response.headers["Content-Type"] = "text/event-stream"
sse = SSE.new(response.stream)
sse.write("{\"name\":\"John\"}")
- sse.write({ name: "Ryan" })
+ sse.write(name: "Ryan")
ensure
sse.close
end
@@ -19,7 +19,7 @@ module ActionController
def sse_with_event
sse = SSE.new(response.stream, event: "send-name")
sse.write("{\"name\":\"John\"}")
- sse.write({ name: "Ryan" })
+ sse.write(name: "Ryan")
ensure
sse.close
end
@@ -459,7 +459,7 @@ class LiveStreamRouterTest < ActionDispatch::IntegrationTest
response.headers["Content-Type"] = "text/event-stream"
sse = SSE.new(response.stream)
sse.write("{\"name\":\"John\"}")
- sse.write({ name: "Ryan" })
+ sse.write(name: "Ryan")
ensure
sse.close
end
diff --git a/actionpack/test/controller/new_base/render_action_test.rb b/actionpack/test/controller/new_base/render_action_test.rb
index b92f86da58..f87c29f977 100644
--- a/actionpack/test/controller/new_base/render_action_test.rb
+++ b/actionpack/test/controller/new_base/render_action_test.rb
@@ -260,11 +260,9 @@ end
module RenderActionWithBothLayouts
class BasicController < ActionController::Base
- self.view_paths = [ActionView::FixtureResolver.new({
- "render_action_with_both_layouts/basic/hello_world.html.erb" => "Hello World!",
+ self.view_paths = [ActionView::FixtureResolver.new( "render_action_with_both_layouts/basic/hello_world.html.erb" => "Hello World!",
"layouts/application.html.erb" => "Oh Hi <%= yield %> Bye",
- "layouts/render_action_with_both_layouts/basic.html.erb" => "With Controller Layout! <%= yield %> Bye"
- })]
+ "layouts/render_action_with_both_layouts/basic.html.erb" => "With Controller Layout! <%= yield %> Bye")]
def hello_world
render action: "hello_world"
diff --git a/actionpack/test/controller/parameters/always_permitted_parameters_test.rb b/actionpack/test/controller/parameters/always_permitted_parameters_test.rb
index 40e2f5152a..9c9749c037 100644
--- a/actionpack/test/controller/parameters/always_permitted_parameters_test.rb
+++ b/actionpack/test/controller/parameters/always_permitted_parameters_test.rb
@@ -19,10 +19,8 @@ class AlwaysPermittedParametersTest < ActiveSupport::TestCase
end
test "permits parameters that are whitelisted" do
- params = ActionController::Parameters.new({
- book: { pages: 65 },
- format: "json"
- })
+ params = ActionController::Parameters.new( book: { pages: 65 },
+ format: "json")
permitted = params.permit book: [:pages]
assert permitted.permitted?
end
diff --git a/actionpack/test/controller/parameters/log_on_unpermitted_params_test.rb b/actionpack/test/controller/parameters/log_on_unpermitted_params_test.rb
index b1a9b9176c..a6e48b8ded 100644
--- a/actionpack/test/controller/parameters/log_on_unpermitted_params_test.rb
+++ b/actionpack/test/controller/parameters/log_on_unpermitted_params_test.rb
@@ -11,10 +11,8 @@ class LogOnUnpermittedParamsTest < ActiveSupport::TestCase
end
test "logs on unexpected param" do
- params = ActionController::Parameters.new({
- book: { pages: 65 },
- fishing: "Turnips"
- })
+ params = ActionController::Parameters.new( book: { pages: 65 },
+ fishing: "Turnips")
assert_logged("Unpermitted parameter: fishing") do
params.permit(book: [:pages])
@@ -22,11 +20,9 @@ class LogOnUnpermittedParamsTest < ActiveSupport::TestCase
end
test "logs on unexpected params" do
- params = ActionController::Parameters.new({
- book: { pages: 65 },
+ params = ActionController::Parameters.new( book: { pages: 65 },
fishing: "Turnips",
- car: "Mersedes"
- })
+ car: "Mersedes")
assert_logged("Unpermitted parameters: fishing, car") do
params.permit(book: [:pages])
@@ -34,9 +30,7 @@ class LogOnUnpermittedParamsTest < ActiveSupport::TestCase
end
test "logs on unexpected nested param" do
- params = ActionController::Parameters.new({
- book: { pages: 65, title: "Green Cats and where to find then." }
- })
+ params = ActionController::Parameters.new( book: { pages: 65, title: "Green Cats and where to find then." })
assert_logged("Unpermitted parameter: title") do
params.permit(book: [:pages])
@@ -44,9 +38,7 @@ class LogOnUnpermittedParamsTest < ActiveSupport::TestCase
end
test "logs on unexpected nested params" do
- params = ActionController::Parameters.new({
- book: { pages: 65, title: "Green Cats and where to find then.", author: "G. A. Dog" }
- })
+ params = ActionController::Parameters.new( book: { pages: 65, title: "Green Cats and where to find then.", author: "G. A. Dog" })
assert_logged("Unpermitted parameters: title, author") do
params.permit(book: [:pages])
diff --git a/actionpack/test/controller/parameters/multi_parameter_attributes_test.rb b/actionpack/test/controller/parameters/multi_parameter_attributes_test.rb
index 1009f533a4..44e39135a2 100644
--- a/actionpack/test/controller/parameters/multi_parameter_attributes_test.rb
+++ b/actionpack/test/controller/parameters/multi_parameter_attributes_test.rb
@@ -3,8 +3,7 @@ require "action_controller/metal/strong_parameters"
class MultiParameterAttributesTest < ActiveSupport::TestCase
test "permitted multi-parameter attribute keys" do
- params = ActionController::Parameters.new({
- book: {
+ params = ActionController::Parameters.new( book: {
"shipped_at(1i)" => "2012",
"shipped_at(2i)" => "3",
"shipped_at(3i)" => "25",
@@ -15,8 +14,7 @@ class MultiParameterAttributesTest < ActiveSupport::TestCase
"published_at(3i)" => "5",
"price(1)" => "R$",
"price(2f)" => "2.02"
- }
- })
+ })
permitted = params.permit book: [ :shipped_at, :price ]
diff --git a/actionpack/test/controller/parameters/nested_parameters_permit_test.rb b/actionpack/test/controller/parameters/nested_parameters_permit_test.rb
index f3c1caee61..e3f1ba5f0a 100644
--- a/actionpack/test/controller/parameters/nested_parameters_permit_test.rb
+++ b/actionpack/test/controller/parameters/nested_parameters_permit_test.rb
@@ -7,8 +7,7 @@ class NestedParametersPermitTest < ActiveSupport::TestCase
end
test "permitted nested parameters" do
- params = ActionController::Parameters.new({
- book: {
+ params = ActionController::Parameters.new( book: {
title: "Romeo and Juliet",
authors: [{
name: "William Shakespeare",
@@ -26,8 +25,7 @@ class NestedParametersPermitTest < ActiveSupport::TestCase
isbn: "x"
}
},
- magazine: "Mjallo!"
- })
+ magazine: "Mjallo!")
permitted = params.permit book: [ :title, { authors: [ :name ] }, { details: :pages }, :id ]
@@ -45,14 +43,12 @@ class NestedParametersPermitTest < ActiveSupport::TestCase
end
test "permitted nested parameters with a string or a symbol as a key" do
- params = ActionController::Parameters.new({
- book: {
+ params = ActionController::Parameters.new( book: {
"authors" => [
{ name: "William Shakespeare", born: "1564-04-26" },
{ name: "Christopher Marlowe" }
]
- }
- })
+ })
permitted = params.permit book: [ { "authors" => [ :name ] } ]
@@ -70,24 +66,20 @@ class NestedParametersPermitTest < ActiveSupport::TestCase
end
test "nested arrays with strings" do
- params = ActionController::Parameters.new({
- book: {
+ params = ActionController::Parameters.new( book: {
genres: ["Tragedy"]
- }
- })
+ })
permitted = params.permit book: {genres: []}
assert_equal ["Tragedy"], permitted[:book][:genres]
end
test "permit may specify symbols or strings" do
- params = ActionController::Parameters.new({
- book: {
+ params = ActionController::Parameters.new( book: {
title: "Romeo and Juliet",
author: "William Shakespeare"
},
- magazine: "Shakespeare Today"
- })
+ magazine: "Shakespeare Today")
permitted = params.permit({book: ["title", :author]}, "magazine")
assert_equal "Romeo and Juliet", permitted[:book][:title]
@@ -96,23 +88,19 @@ class NestedParametersPermitTest < ActiveSupport::TestCase
end
test "nested array with strings that should be hashes" do
- params = ActionController::Parameters.new({
- book: {
+ params = ActionController::Parameters.new( book: {
genres: ["Tragedy"]
- }
- })
+ })
permitted = params.permit book: { genres: :type }
assert_empty permitted[:book][:genres]
end
test "nested array with strings that should be hashes and additional values" do
- params = ActionController::Parameters.new({
- book: {
+ params = ActionController::Parameters.new( book: {
title: "Romeo and Juliet",
genres: ["Tragedy"]
- }
- })
+ })
permitted = params.permit book: [ :title, { genres: :type } ]
assert_equal "Romeo and Juliet", permitted[:book][:title]
@@ -120,26 +108,22 @@ class NestedParametersPermitTest < ActiveSupport::TestCase
end
test "nested string that should be a hash" do
- params = ActionController::Parameters.new({
- book: {
+ params = ActionController::Parameters.new( book: {
genre: "Tragedy"
- }
- })
+ })
permitted = params.permit book: { genre: :type }
assert_nil permitted[:book][:genre]
end
test "fields_for-style nested params" do
- params = ActionController::Parameters.new({
- book: {
+ params = ActionController::Parameters.new( book: {
authors_attributes: {
'0': { name: "William Shakespeare", age_of_death: "52" },
'1': { name: "Unattributed Assistant" },
'2': { name: %w(injected names) }
}
- }
- })
+ })
permitted = params.permit book: { authors_attributes: [ :name ] }
assert_not_nil permitted[:book][:authors_attributes]["0"]
@@ -152,14 +136,12 @@ class NestedParametersPermitTest < ActiveSupport::TestCase
end
test "fields_for-style nested params with negative numbers" do
- params = ActionController::Parameters.new({
- book: {
+ params = ActionController::Parameters.new( book: {
authors_attributes: {
'-1': { name: "William Shakespeare", age_of_death: "52" },
'-2': { name: "Unattributed Assistant" }
}
- }
- })
+ })
permitted = params.permit book: { authors_attributes: [:name] }
assert_not_nil permitted[:book][:authors_attributes]["-1"]
@@ -171,14 +153,12 @@ class NestedParametersPermitTest < ActiveSupport::TestCase
end
test "nested number as key" do
- params = ActionController::Parameters.new({
- product: {
+ params = ActionController::Parameters.new( product: {
properties: {
"0" => "prop0",
"1" => "prop1"
}
- }
- })
+ })
params = params.require(:product).permit(properties: ["0"])
assert_not_nil params[:properties]["0"]
assert_nil params[:properties]["1"]
diff --git a/actionpack/test/controller/parameters/parameters_permit_test.rb b/actionpack/test/controller/parameters/parameters_permit_test.rb
index ca59e670b9..7467d5a78f 100644
--- a/actionpack/test/controller/parameters/parameters_permit_test.rb
+++ b/actionpack/test/controller/parameters/parameters_permit_test.rb
@@ -256,9 +256,9 @@ class ParametersPermitTest < ActiveSupport::TestCase
test "permitted takes a default value when Parameters.permit_all_parameters is set" do
begin
ActionController::Parameters.permit_all_parameters = true
- params = ActionController::Parameters.new({ person: {
+ params = ActionController::Parameters.new(person: {
age: "32", name: { first: "David", last: "Heinemeier Hansson" }
- }})
+ })
assert params.slice(:person).permitted?
assert params[:person][:name].permitted?
diff --git a/actionpack/test/controller/parameters/raise_on_unpermitted_params_test.rb b/actionpack/test/controller/parameters/raise_on_unpermitted_params_test.rb
index 80a057dbac..bcb16eaf89 100644
--- a/actionpack/test/controller/parameters/raise_on_unpermitted_params_test.rb
+++ b/actionpack/test/controller/parameters/raise_on_unpermitted_params_test.rb
@@ -11,10 +11,8 @@ class RaiseOnUnpermittedParamsTest < ActiveSupport::TestCase
end
test "raises on unexpected params" do
- params = ActionController::Parameters.new({
- book: { pages: 65 },
- fishing: "Turnips"
- })
+ params = ActionController::Parameters.new( book: { pages: 65 },
+ fishing: "Turnips")
assert_raises(ActionController::UnpermittedParameters) do
params.permit(book: [:pages])
@@ -22,9 +20,7 @@ class RaiseOnUnpermittedParamsTest < ActiveSupport::TestCase
end
test "raises on unexpected nested params" do
- params = ActionController::Parameters.new({
- book: { pages: 65, title: "Green Cats and where to find then." }
- })
+ params = ActionController::Parameters.new( book: { pages: 65, title: "Green Cats and where to find then." })
assert_raises(ActionController::UnpermittedParameters) do
params.permit(book: [:pages])
diff --git a/actionpack/test/controller/params_wrapper_test.rb b/actionpack/test/controller/params_wrapper_test.rb
index c1f1f33dc0..7d49e8d114 100644
--- a/actionpack/test/controller/params_wrapper_test.rb
+++ b/actionpack/test/controller/params_wrapper_test.rb
@@ -4,7 +4,7 @@ module Admin; class User; end; end
module ParamsWrapperTestHelp
def with_default_wrapper_options(&block)
- @controller.class._set_wrapper_options({format: [:json]})
+ @controller.class._set_wrapper_options(format: [:json])
@controller.class.inherited(@controller.class)
yield
end
@@ -50,7 +50,7 @@ class ParamsWrapperTest < ActionController::TestCase
with_default_wrapper_options do
@request.env["CONTENT_TYPE"] = "application/json"
post :parse, params: { "username" => "sikachu" }
- assert_equal @request.filtered_parameters, { "controller" => "params_wrapper_test/users", "action" => "parse", "username" => "sikachu", "user" => { "username" => "sikachu" } }
+ assert_equal @request.filtered_parameters, "controller" => "params_wrapper_test/users", "action" => "parse", "username" => "sikachu", "user" => { "username" => "sikachu" }
end
end
@@ -58,7 +58,7 @@ class ParamsWrapperTest < ActionController::TestCase
with_default_wrapper_options do
@request.env["CONTENT_TYPE"] = "application/json"
post :parse, params: { "username" => "sikachu" }
- assert_parameters({ "username" => "sikachu", "user" => { "username" => "sikachu" }})
+ assert_parameters("username" => "sikachu", "user" => { "username" => "sikachu" })
end
end
@@ -68,7 +68,7 @@ class ParamsWrapperTest < ActionController::TestCase
@request.env["CONTENT_TYPE"] = "application/json"
post :parse, params: { "username" => "sikachu" }
- assert_parameters({ "username" => "sikachu", "person" => { "username" => "sikachu" }})
+ assert_parameters("username" => "sikachu", "person" => { "username" => "sikachu" })
end
end
@@ -78,7 +78,7 @@ class ParamsWrapperTest < ActionController::TestCase
@request.env["CONTENT_TYPE"] = "application/json"
post :parse, params: { "username" => "sikachu" }
- assert_parameters({ "username" => "sikachu", "person" => { "username" => "sikachu" }})
+ assert_parameters("username" => "sikachu", "person" => { "username" => "sikachu" })
end
end
@@ -88,7 +88,7 @@ class ParamsWrapperTest < ActionController::TestCase
@request.env["CONTENT_TYPE"] = "application/json"
post :parse, params: { "username" => "sikachu", "title" => "Developer" }
- assert_parameters({ "username" => "sikachu", "title" => "Developer", "user" => { "username" => "sikachu" }})
+ assert_parameters("username" => "sikachu", "title" => "Developer", "user" => { "username" => "sikachu" })
end
end
@@ -98,7 +98,7 @@ class ParamsWrapperTest < ActionController::TestCase
@request.env["CONTENT_TYPE"] = "application/json"
post :parse, params: { "username" => "sikachu", "title" => "Developer" }
- assert_parameters({ "username" => "sikachu", "title" => "Developer", "user" => { "username" => "sikachu" }})
+ assert_parameters("username" => "sikachu", "title" => "Developer", "user" => { "username" => "sikachu" })
end
end
@@ -108,7 +108,7 @@ class ParamsWrapperTest < ActionController::TestCase
@request.env["CONTENT_TYPE"] = "application/json"
post :parse, params: { "username" => "sikachu", "title" => "Developer" }
- assert_parameters({ "username" => "sikachu", "title" => "Developer", "person" => { "username" => "sikachu" }})
+ assert_parameters("username" => "sikachu", "title" => "Developer", "person" => { "username" => "sikachu" })
end
end
@@ -116,7 +116,7 @@ class ParamsWrapperTest < ActionController::TestCase
with_default_wrapper_options do
@request.env["CONTENT_TYPE"] = "application/xml"
post :parse, params: { "username" => "sikachu", "title" => "Developer" }
- assert_parameters({ "username" => "sikachu", "title" => "Developer" })
+ assert_parameters("username" => "sikachu", "title" => "Developer")
end
end
@@ -125,7 +125,7 @@ class ParamsWrapperTest < ActionController::TestCase
UsersController.wrap_parameters false
@request.env["CONTENT_TYPE"] = "application/json"
post :parse, params: { "username" => "sikachu", "title" => "Developer" }
- assert_parameters({ "username" => "sikachu", "title" => "Developer" })
+ assert_parameters("username" => "sikachu", "title" => "Developer")
end
end
@@ -135,7 +135,7 @@ class ParamsWrapperTest < ActionController::TestCase
@request.env["CONTENT_TYPE"] = "application/xml"
post :parse, params: { "username" => "sikachu", "title" => "Developer" }
- assert_parameters({ "username" => "sikachu", "title" => "Developer", "user" => { "username" => "sikachu", "title" => "Developer" }})
+ assert_parameters("username" => "sikachu", "title" => "Developer", "user" => { "username" => "sikachu", "title" => "Developer" })
end
end
@@ -143,7 +143,7 @@ class ParamsWrapperTest < ActionController::TestCase
with_default_wrapper_options do
@request.env["CONTENT_TYPE"] = "application/json"
post :parse, params: { "authenticity_token" => "pwned", "_method" => "put", "utf8" => "&#9731;", "username" => "sikachu" }
- assert_parameters({ "authenticity_token" => "pwned", "_method" => "put", "utf8" => "&#9731;", "username" => "sikachu", "user" => { "username" => "sikachu" }})
+ assert_parameters("authenticity_token" => "pwned", "_method" => "put", "utf8" => "&#9731;", "username" => "sikachu", "user" => { "username" => "sikachu" })
end
end
@@ -151,7 +151,7 @@ class ParamsWrapperTest < ActionController::TestCase
with_default_wrapper_options do
@request.env["CONTENT_TYPE"] = "application/json"
post :parse, params: { "user" => { "username" => "sikachu" }}
- assert_parameters({ "user" => { "username" => "sikachu" }})
+ assert_parameters("user" => { "username" => "sikachu" })
end
end
@@ -159,7 +159,7 @@ class ParamsWrapperTest < ActionController::TestCase
with_default_wrapper_options do
@request.env["CONTENT_TYPE"] = "application/json"
post :parse, params: { "person" => { "username" => "sikachu" }}
- assert_parameters({ "person" => { "username" => "sikachu" }, "user" => {"person" => { "username" => "sikachu" }}})
+ assert_parameters("person" => { "username" => "sikachu" }, "user" => {"person" => { "username" => "sikachu" }})
end
end
@@ -168,7 +168,7 @@ class ParamsWrapperTest < ActionController::TestCase
with_default_wrapper_options do
@request.env["CONTENT_TYPE"] = "application/json"
post :parse, params: { "username" => "sikachu", "title" => "Developer" }
- assert_parameters({ "username" => "sikachu", "title" => "Developer", "user" => { "username" => "sikachu" }})
+ assert_parameters("username" => "sikachu", "title" => "Developer", "user" => { "username" => "sikachu" })
end
end
end
@@ -180,7 +180,7 @@ class ParamsWrapperTest < ActionController::TestCase
@request.env["CONTENT_TYPE"] = "application/json"
post :parse, params: { "username" => "sikachu", "title" => "Developer" }
- assert_parameters({ "username" => "sikachu", "title" => "Developer", "person" => { "username" => "sikachu" }})
+ assert_parameters("username" => "sikachu", "title" => "Developer", "person" => { "username" => "sikachu" })
end
end
end
@@ -189,7 +189,7 @@ class ParamsWrapperTest < ActionController::TestCase
with_default_wrapper_options do
@request.env["CONTENT_TYPE"] = "application/json"
post :parse, params: { "username" => "sikachu", "title" => "Developer" }
- assert_parameters({ "username" => "sikachu", "title" => "Developer", "user" => { "username" => "sikachu", "title" => "Developer" }})
+ assert_parameters("username" => "sikachu", "title" => "Developer", "user" => { "username" => "sikachu", "title" => "Developer" })
end
end
@@ -198,7 +198,7 @@ class ParamsWrapperTest < ActionController::TestCase
@request.env["CONTENT_TYPE"] = "application/json"
get :parse, params: { "user" => { "username" => "nixon" } }
assert_parameters(
- {"user" => { "username" => "nixon" } }
+ "user" => { "username" => "nixon" }
)
end
end
@@ -208,7 +208,7 @@ class ParamsWrapperTest < ActionController::TestCase
@request.env["CONTENT_TYPE"] = "application/json"
post :parse, params: {}
assert_parameters(
- {"user" => { } }
+ "user" => { }
)
end
end
@@ -254,7 +254,7 @@ class NamespacedParamsWrapperTest < ActionController::TestCase
with_default_wrapper_options do
@request.env["CONTENT_TYPE"] = "application/json"
post :parse, params: { "username" => "sikachu" }
- assert_parameters({"username" => "sikachu", "user" => { "username" => "sikachu" }})
+ assert_parameters("username" => "sikachu", "user" => { "username" => "sikachu" })
end
end
@@ -264,7 +264,7 @@ class NamespacedParamsWrapperTest < ActionController::TestCase
with_default_wrapper_options do
@request.env["CONTENT_TYPE"] = "application/json"
post :parse, params: { "username" => "sikachu", "title" => "Developer" }
- assert_parameters({ "username" => "sikachu", "title" => "Developer", "user" => { "username" => "sikachu" }})
+ assert_parameters("username" => "sikachu", "title" => "Developer", "user" => { "username" => "sikachu" })
end
ensure
Admin.send :remove_const, :User
@@ -277,7 +277,7 @@ class NamespacedParamsWrapperTest < ActionController::TestCase
with_default_wrapper_options do
@request.env["CONTENT_TYPE"] = "application/json"
post :parse, params: { "username" => "sikachu", "title" => "Developer" }
- assert_parameters({ "username" => "sikachu", "title" => "Developer", "user" => { "title" => "Developer" }})
+ assert_parameters("username" => "sikachu", "title" => "Developer", "user" => { "title" => "Developer" })
end
ensure
Object.send :remove_const, :User
@@ -304,7 +304,7 @@ class AnonymousControllerParamsWrapperTest < ActionController::TestCase
with_default_wrapper_options do
@request.env["CONTENT_TYPE"] = "application/json"
post :parse, params: { "username" => "sikachu" }
- assert_parameters({ "username" => "sikachu" })
+ assert_parameters("username" => "sikachu")
end
end
@@ -313,7 +313,7 @@ class AnonymousControllerParamsWrapperTest < ActionController::TestCase
@controller.class.wrap_parameters(name: "guest")
@request.env["CONTENT_TYPE"] = "application/json"
post :parse, params: { "username" => "sikachu" }
- assert_parameters({ "username" => "sikachu", "guest" => { "username" => "sikachu" }})
+ assert_parameters("username" => "sikachu", "guest" => { "username" => "sikachu" })
end
end
end
@@ -349,7 +349,7 @@ class IrregularInflectionParamsWrapperTest < ActionController::TestCase
with_default_wrapper_options do
@request.env["CONTENT_TYPE"] = "application/json"
post :parse, params: { "username" => "sikachu", "test_attr" => "test_value" }
- assert_parameters({ "username" => "sikachu", "test_attr" => "test_value", "paramswrappernews_item" => { "test_attr" => "test_value" }})
+ assert_parameters("username" => "sikachu", "test_attr" => "test_value", "paramswrappernews_item" => { "test_attr" => "test_value" })
end
end
end
diff --git a/actionpack/test/controller/redirect_test.rb b/actionpack/test/controller/redirect_test.rb
index 9ce647d26e..0539580e14 100644
--- a/actionpack/test/controller/redirect_test.rb
+++ b/actionpack/test/controller/redirect_test.rb
@@ -29,11 +29,11 @@ class RedirectController < ActionController::Base
end
def redirect_with_status
- redirect_to({action: "hello_world", status: 301})
+ redirect_to(action: "hello_world", status: 301)
end
def redirect_with_status_hash
- redirect_to({action: "hello_world"}, {status: 301})
+ redirect_to({action: "hello_world"}, status: 301)
end
def redirect_with_protocol
@@ -45,7 +45,7 @@ class RedirectController < ActionController::Base
end
def url_redirect_with_status_hash
- redirect_to("http://www.example.com", {status: 301})
+ redirect_to("http://www.example.com", status: 301)
end
def relative_url_redirect_with_status
@@ -53,7 +53,7 @@ class RedirectController < ActionController::Base
end
def relative_url_redirect_with_status_hash
- redirect_to("/things/stuff", {status: 301})
+ redirect_to("/things/stuff", status: 301)
end
def redirect_to_back_with_status
diff --git a/actionpack/test/controller/renderer_test.rb b/actionpack/test/controller/renderer_test.rb
index a5465f55fa..d6f09f2d90 100644
--- a/actionpack/test/controller/renderer_test.rb
+++ b/actionpack/test/controller/renderer_test.rb
@@ -88,7 +88,7 @@ class RendererTest < ActiveSupport::TestCase
end
test "rendering with user specified defaults" do
- ApplicationController.renderer.defaults.merge!({ hello: "hello", https: true })
+ ApplicationController.renderer.defaults.merge!(hello: "hello", https: true)
renderer = ApplicationController.renderer.new
content = renderer.render inline: "<%= request.ssl? %>"
diff --git a/actionpack/test/controller/required_params_test.rb b/actionpack/test/controller/required_params_test.rb
index 6de954700f..15131b3217 100644
--- a/actionpack/test/controller/required_params_test.rb
+++ b/actionpack/test/controller/required_params_test.rb
@@ -75,7 +75,7 @@ class ParametersRequireTest < ActiveSupport::TestCase
test "Deprecated methods are deprecated" do
assert_deprecated do
- ActionController::Parameters.new(foo: "bar").merge!({bar: "foo"})
+ ActionController::Parameters.new(foo: "bar").merge!(bar: "foo")
end
end
end
diff --git a/actionpack/test/controller/resources_test.rb b/actionpack/test/controller/resources_test.rb
index 2514991d7d..36df54e1ff 100644
--- a/actionpack/test/controller/resources_test.rb
+++ b/actionpack/test/controller/resources_test.rb
@@ -1067,7 +1067,7 @@ class ResourcesTest < ActionController::TestCase
match "/products", to: "products#show", via: :all
end
- assert_routing({ method: "all", path: "/products" }, { controller: "products", action: "show" })
+ assert_routing({ method: "all", path: "/products" }, controller: "products", action: "show")
end
end
@@ -1078,7 +1078,7 @@ class ResourcesTest < ActionController::TestCase
end
assert_raises(Minitest::Assertion) do
- assert_routing({ method: "all", path: "/products" }, { controller: "products", action: "show" })
+ assert_routing({ method: "all", path: "/products" }, controller: "products", action: "show")
end
end
end
diff --git a/actionpack/test/controller/routing_test.rb b/actionpack/test/controller/routing_test.rb
index 7d506c1976..0b2c7b7a4f 100644
--- a/actionpack/test/controller/routing_test.rb
+++ b/actionpack/test/controller/routing_test.rb
@@ -29,12 +29,10 @@ class UriReservedCharactersRoutingTest < ActiveSupport::TestCase
def test_route_generation_escapes_unsafe_path_characters
assert_equal "/content/act#{@escaped}ion/var#{@escaped}iable/add#{@escaped}itional-1/add#{@escaped}itional-2",
- url_for(@set, {
- controller: "content",
+ url_for(@set, controller: "content",
action: "act#{@segment}ion",
variable: "var#{@segment}iable",
- additional: ["add#{@segment}itional-1", "add#{@segment}itional-2"]
- })
+ additional: ["add#{@segment}itional-1", "add#{@segment}itional-2"])
end
def test_route_recognition_unescapes_path_components
@@ -47,12 +45,10 @@ class UriReservedCharactersRoutingTest < ActiveSupport::TestCase
def test_route_generation_allows_passing_non_string_values_to_generated_helper
assert_equal "/content/action/variable/1/2",
- url_for(@set, {
- controller: "content",
+ url_for(@set, controller: "content",
action: "action",
variable: "variable",
- additional: [1, 2]
- })
+ additional: [1, 2])
end
end
@@ -309,18 +305,18 @@ class LegacyRouteSetTests < ActiveSupport::TestCase
assert_equal({controller: "admin/user", action: "show", id: "10"}, rs.recognize_path("/admin/user/show/10"))
- assert_equal "/admin/user/show/10", url_for(rs, { controller: "admin/user", action: "show", id: 10 })
+ assert_equal "/admin/user/show/10", url_for(rs, controller: "admin/user", action: "show", id: 10)
get URI("http://test.host/admin/user/list/10")
assert_equal({ controller: "admin/user", action: "list", id: "10" },
controller.request.path_parameters)
- assert_equal "/admin/user/show", controller.url_for({ action: "show", only_path: true })
- assert_equal "/admin/user/list/10", controller.url_for({only_path: true})
+ assert_equal "/admin/user/show", controller.url_for(action: "show", only_path: true)
+ assert_equal "/admin/user/list/10", controller.url_for(only_path: true)
- assert_equal "/admin/stuff", controller.url_for({ controller: "stuff", only_path: true })
- assert_equal "/stuff", controller.url_for({ controller: "/stuff", only_path: true })
+ assert_equal "/admin/stuff", controller.url_for(controller: "stuff", only_path: true)
+ assert_equal "/stuff", controller.url_for(controller: "/stuff", only_path: true)
end
def test_route_with_colon_first
@@ -341,8 +337,8 @@ class LegacyRouteSetTests < ActiveSupport::TestCase
assert_equal({ action: "auth_google", controller: "content" }, rs.recognize_path("/content/auth_google"))
assert_equal({ action: "auth-facebook", controller: "content" }, rs.recognize_path("/content/auth-facebook"))
- assert_equal "/content/auth_google", url_for(rs, { controller: "content", action: "auth_google" })
- assert_equal "/content/auth-facebook", url_for(rs, { controller: "content", action: "auth-facebook" })
+ assert_equal "/content/auth_google", url_for(rs, controller: "content", action: "auth_google")
+ assert_equal "/content/auth-facebook", url_for(rs, controller: "content", action: "auth-facebook")
end
def test_route_with_regexp_for_controller
@@ -358,8 +354,8 @@ class LegacyRouteSetTests < ActiveSupport::TestCase
assert_equal({controller: "content", action: "foo"},
rs.recognize_path("/content/foo"))
- assert_equal "/admin/user/foo", url_for(rs, { controller: "admin/user", admintoken: "foo", action: "index" })
- assert_equal "/content/foo", url_for(rs, { controller: "content", action: "foo" })
+ assert_equal "/admin/user/foo", url_for(rs, controller: "admin/user", admintoken: "foo", action: "index")
+ assert_equal "/content/foo", url_for(rs, controller: "content", action: "foo")
end
def test_route_with_regexp_and_captures_for_controller
@@ -385,14 +381,14 @@ class LegacyRouteSetTests < ActiveSupport::TestCase
end
# Without a file extension
assert_equal "/user/download/file",
- url_for(rs, { controller: "user", action: "download", file: "file" })
+ url_for(rs, controller: "user", action: "download", file: "file")
assert_equal({controller: "user", action: "download", file: "file"},
rs.recognize_path("/user/download/file"))
# Now, let's try a file with an extension, really a dot (.)
assert_equal "/user/download/file.jpg",
- url_for(rs, { controller: "user", action: "download", file: "file.jpg" })
+ url_for(rs, controller: "user", action: "download", file: "file.jpg")
assert_equal({controller: "user", action: "download", file: "file.jpg"},
rs.recognize_path("/user/download/file.jpg"))
@@ -540,7 +536,7 @@ class LegacyRouteSetTests < ActiveSupport::TestCase
get URI("http://test.host/admin/user/index/10")
assert_equal "/admin/stuff/show/10",
- controller.url_for({controller: "stuff", action: "show", id: 10, only_path: true})
+ controller.url_for(controller: "stuff", action: "show", id: 10, only_path: true)
end
def test_paths_escaped
@@ -586,7 +582,7 @@ class LegacyRouteSetTests < ActiveSupport::TestCase
get "post/:id" => "post#show", :constraints => { id: /\d+/ }, :as => "post"
end
assert_raise(ActionController::UrlGenerationError) do
- url_for(rs, { controller: "post", action: "show", bad_param: "foo", use_route: "post" })
+ url_for(rs, controller: "post", action: "show", bad_param: "foo", use_route: "post")
end
end
@@ -596,7 +592,7 @@ class LegacyRouteSetTests < ActiveSupport::TestCase
end
assert_equal "/pages/boo",
- url_for(rs, { controller: "content", action: "show_file", path: %w(pages boo) })
+ url_for(rs, controller: "content", action: "show_file", path: %w(pages boo))
end
def test_dynamic_recall_paths_allowed
@@ -621,9 +617,9 @@ class LegacyRouteSetTests < ActiveSupport::TestCase
end
get URI("http://test.host/pages/show")
- assert_equal "/page/20", controller.url_for({ id: 20, only_path: true })
- assert_equal "/page/20", url_for(rs, { controller: "pages", id: 20, action: "show" })
- assert_equal "/pages/boo", url_for(rs, { controller: "pages", action: "boo" })
+ assert_equal "/page/20", controller.url_for(id: 20, only_path: true)
+ assert_equal "/page/20", url_for(rs, controller: "pages", id: 20, action: "show")
+ assert_equal "/pages/boo", url_for(rs, controller: "pages", action: "boo")
end
def test_route_with_integer_default
@@ -635,10 +631,10 @@ class LegacyRouteSetTests < ActiveSupport::TestCase
end
end
- assert_equal "/page", url_for(rs, { controller: "content", action: "show_page" })
- assert_equal "/page", url_for(rs, { controller: "content", action: "show_page", id: 1 })
- assert_equal "/page", url_for(rs, { controller: "content", action: "show_page", id: "1" })
- assert_equal "/page/10", url_for(rs, { controller: "content", action: "show_page", id: 10 })
+ assert_equal "/page", url_for(rs, controller: "content", action: "show_page")
+ assert_equal "/page", url_for(rs, controller: "content", action: "show_page", id: 1)
+ assert_equal "/page", url_for(rs, controller: "content", action: "show_page", id: "1")
+ assert_equal "/page/10", url_for(rs, controller: "content", action: "show_page", id: 10)
assert_equal({controller: "content", action: "show_page", id: 1 }, rs.recognize_path("/page"))
assert_equal({controller: "content", action: "show_page", id: "1"}, rs.recognize_path("/page/1"))
@@ -655,14 +651,14 @@ class LegacyRouteSetTests < ActiveSupport::TestCase
end
end
- assert_equal "/page/foo", url_for(rs, { controller: "content", action: "show_page", id: "foo" })
+ assert_equal "/page/foo", url_for(rs, controller: "content", action: "show_page", id: "foo")
assert_equal({ controller: "content", action: "show_page", id: "foo" }, rs.recognize_path("/page/foo"))
token = "\321\202\320\265\320\272\321\201\321\202" # 'text' in Russian
token.force_encoding(Encoding::BINARY)
escaped_token = CGI::escape(token)
- assert_equal "/page/" + escaped_token, url_for(rs, { controller: "content", action: "show_page", id: token })
+ assert_equal "/page/" + escaped_token, url_for(rs, controller: "content", action: "show_page", id: token)
assert_equal({ controller: "content", action: "show_page", id: token }, rs.recognize_path("/page/#{escaped_token}"))
end
@@ -677,10 +673,10 @@ class LegacyRouteSetTests < ActiveSupport::TestCase
get "post/:id" => "post#show", :constraints => {id: /\d+/}, :as => "post"
end
- assert_equal "/post/10", url_for(rs, { controller: "post", action: "show", id: 10 })
+ assert_equal "/post/10", url_for(rs, controller: "post", action: "show", id: 10)
assert_raise(ActionController::UrlGenerationError) do
- url_for(rs, { controller: "post", action: "show" })
+ url_for(rs, controller: "post", action: "show")
end
end
@@ -696,8 +692,8 @@ class LegacyRouteSetTests < ActiveSupport::TestCase
end
end
- assert_equal "/test", url_for(rs, { controller: "post", action: "show" })
- assert_equal "/test", url_for(rs, { controller: "post", action: "show", year: nil })
+ assert_equal "/test", url_for(rs, controller: "post", action: "show")
+ assert_equal "/test", url_for(rs, controller: "post", action: "show", year: nil)
assert_equal("http://test.host/test", setup_for_named_route.send(:blog_url))
end
@@ -712,24 +708,24 @@ class LegacyRouteSetTests < ActiveSupport::TestCase
end
assert_equal "/pages/2005",
- url_for(rs, { controller: "content", action: "list_pages", year: 2005 })
+ url_for(rs, controller: "content", action: "list_pages", year: 2005)
assert_equal "/pages/2005/6",
- url_for(rs, { controller: "content", action: "list_pages", year: 2005, month: 6 })
+ url_for(rs, controller: "content", action: "list_pages", year: 2005, month: 6)
assert_equal "/pages/2005/6/12",
- url_for(rs, { controller: "content", action: "list_pages", year: 2005, month: 6, day: 12 })
+ url_for(rs, controller: "content", action: "list_pages", year: 2005, month: 6, day: 12)
get URI("http://test.host/pages/2005/6/12")
assert_equal({ controller: "content", action: "list_pages", year: "2005", month: "6", day: "12" },
controller.request.path_parameters)
assert_equal "/pages/2005/6/4",
- controller.url_for({ day: 4, only_path: true })
+ controller.url_for(day: 4, only_path: true)
assert_equal "/pages/2005/6",
- controller.url_for({ day: nil, only_path: true })
+ controller.url_for(day: nil, only_path: true)
assert_equal "/pages/2005",
- controller.url_for({ day: nil, month: nil, only_path: true })
+ controller.url_for(day: nil, month: nil, only_path: true)
end
def test_root_url_generation_with_controller_and_action
@@ -737,8 +733,8 @@ class LegacyRouteSetTests < ActiveSupport::TestCase
root to: "content#index"
end
- assert_equal "/", url_for(rs, { controller: "content", action: "index" })
- assert_equal "/", url_for(rs, { controller: "content" })
+ assert_equal "/", url_for(rs, controller: "content", action: "index")
+ assert_equal "/", url_for(rs, controller: "content")
end
def test_named_root_url_generation_with_controller_and_action
@@ -746,8 +742,8 @@ class LegacyRouteSetTests < ActiveSupport::TestCase
root to: "content#index", as: "home"
end
- assert_equal "/", url_for(rs, { controller: "content", action: "index" })
- assert_equal "/", url_for(rs, { controller: "content" })
+ assert_equal "/", url_for(rs, controller: "content", action: "index")
+ assert_equal "/", url_for(rs, controller: "content")
assert_equal("http://test.host/", setup_for_named_route.send(:home_url))
end
@@ -761,8 +757,8 @@ class LegacyRouteSetTests < ActiveSupport::TestCase
end
end
- assert_equal "/categories", url_for(rs, { controller: "content", action: "categories" })
- assert_equal "/content/hi", url_for(rs, { controller: "content", action: "hi" })
+ assert_equal "/categories", url_for(rs, controller: "content", action: "categories")
+ assert_equal "/content/hi", url_for(rs, controller: "content", action: "hi")
end
def test_named_routes_array
@@ -780,12 +776,10 @@ class LegacyRouteSetTests < ActiveSupport::TestCase
end
end
- assert_equal "/journal", url_for(rs, {
- controller: "content",
+ assert_equal "/journal", url_for(rs, controller: "content",
action: "list_journal",
date: nil,
- user_id: nil
- })
+ user_id: nil)
end
def setup_request_method_routes_for(method)
@@ -851,9 +845,9 @@ class LegacyRouteSetTests < ActiveSupport::TestCase
end
end
- assert_equal "/books/7/edit", url_for(rs, { controller: "subpath_books", id: 7, action: "edit" })
- assert_equal "/items/15/complete", url_for(rs, { controller: "subpath_books", id: 15, action: "complete" })
- assert_equal "/posts/new/preview", url_for(rs, { controller: "subpath_books", action: "preview" })
+ assert_equal "/books/7/edit", url_for(rs, controller: "subpath_books", id: 7, action: "edit")
+ assert_equal "/items/15/complete", url_for(rs, controller: "subpath_books", id: 15, action: "complete")
+ assert_equal "/posts/new/preview", url_for(rs, controller: "subpath_books", action: "preview")
end
def test_failed_constraints_raises_exception_with_violated_constraints
@@ -964,7 +958,7 @@ class RouteSetTest < ActiveSupport::TestCase
end
end
assert_equal "/foo/bar/15?this=hello",
- url_for(set, { controller: "foo", action: "bar", id: 15, this: "hello" })
+ url_for(set, controller: "foo", action: "bar", id: 15, this: "hello")
end
def test_extra_keys_not_first
@@ -1111,8 +1105,8 @@ class RouteSetTest < ActiveSupport::TestCase
assert_equal 1, set.routes.size
- assert_equal "/users/show/10", url_for(set, { controller: "users", action: "show", id: 10 })
- assert_equal "/users/index/10", url_for(set, { controller: "users", id: 10 })
+ assert_equal "/users/show/10", url_for(set, controller: "users", action: "show", id: 10)
+ assert_equal "/users/index/10", url_for(set, controller: "users", id: 10)
assert_equal({controller: "users", action: "index", id: "10"}, set.recognize_path("/users/index/10"))
assert_equal({controller: "users", action: "index", id: "10"}, set.recognize_path("/users/index/10/"))
@@ -1313,7 +1307,7 @@ class RouteSetTest < ActiveSupport::TestCase
get "/people/list", controller: "people", action: "list"
end
- url = url_for(set, { controller: "people", action: "list" })
+ url = url_for(set, controller: "people", action: "list")
assert_equal "/people/list", url
end
@@ -1456,11 +1450,11 @@ class RouteSetTest < ActiveSupport::TestCase
assert_equal({ controller: "connection/manage",
action: "index", }, request_path_params("/connection/manage"))
- url = controller.url_for({ controller: "connection", only_path: true })
+ url = controller.url_for(controller: "connection", only_path: true)
assert_equal "/connection/connection", url
- url = controller.url_for({ use_route: "family_connection",
- controller: "connection", only_path: true })
+ url = controller.url_for(use_route: "family_connection",
+ controller: "connection", only_path: true)
assert_equal "/connection", url
end
@@ -1494,7 +1488,7 @@ class RouteSetTest < ActiveSupport::TestCase
get URI("http://test.host/weblog/show/1")
assert_equal "/weblog/edit?parameter=1", controller.url_for(
- {action: "edit", parameter: 1, only_path: true})
+ action: "edit", parameter: 1, only_path: true)
end
def test_format_is_not_inherit
@@ -1507,10 +1501,10 @@ class RouteSetTest < ActiveSupport::TestCase
controller.request.path_parameters)
assert_equal "/posts", controller.url_for(
- {controller: "posts", only_path: true})
+ controller: "posts", only_path: true)
assert_equal "/posts.xml", controller.url_for(
- {controller: "posts", format: "xml", only_path: true})
+ controller: "posts", format: "xml", only_path: true)
end
def test_expiry_determination_should_consider_values_with_to_param
@@ -1525,7 +1519,7 @@ class RouteSetTest < ActiveSupport::TestCase
controller.request.path_parameters)
assert_equal "/projects/1/weblog/show",
- controller.url_for({ action: "show", project_id: 1, only_path: true })
+ controller.url_for(action: "show", project_id: 1, only_path: true)
end
def test_named_route_in_nested_resource
@@ -1622,12 +1616,12 @@ class RouteSetTest < ActiveSupport::TestCase
:constraints => {name: /(david|jamis)/i}
end
- url = url_for(set, { controller: "pages", action: "show", name: "david" })
+ url = url_for(set, controller: "pages", action: "show", name: "david")
assert_equal "/page/david", url
assert_raise(ActionController::UrlGenerationError) do
- url_for(set, { controller: "pages", action: "show", name: "davidjamis" })
+ url_for(set, controller: "pages", action: "show", name: "davidjamis")
end
- url = url_for(set, { controller: "pages", action: "show", name: "JAMIS" })
+ url = url_for(set, controller: "pages", action: "show", name: "JAMIS")
assert_equal "/page/JAMIS", url
end
@@ -1666,7 +1660,7 @@ class RouteSetTest < ActiveSupport::TestCase
set.recognize_path("/page/JAMIS"))
assert_equal "/page/JAMIS",
- url_for(set, { controller: "pages", action: "show", name: "JAMIS" })
+ url_for(set, controller: "pages", action: "show", name: "JAMIS")
end
def test_routes_with_symbols
@@ -1684,8 +1678,8 @@ class RouteSetTest < ActiveSupport::TestCase
get "/hello" => "bar#index"
end
- assert_equal "/", url_for(set, { controller: "foo" })
- assert_equal "/hello", url_for(set, { controller: "bar" })
+ assert_equal "/", url_for(set, controller: "foo")
+ assert_equal "/hello", url_for(set, controller: "bar")
assert_equal({controller: "foo", action: "index"}, set.recognize_path("/"))
assert_equal({controller: "bar", action: "index"}, set.recognize_path("/hello"))
@@ -1698,7 +1692,7 @@ class RouteSetTest < ActiveSupport::TestCase
end
end
- assert_equal "/cars/buy/1/2", url_for(set, { controller: "cars", action: "buy", person: "1", car: "2" })
+ assert_equal "/cars/buy/1/2", url_for(set, controller: "cars", action: "buy", person: "1", car: "2")
assert_equal({controller: "cars", action: "buy", person: "1", car: "2"}, set.recognize_path("/cars/buy/1/2"))
end
@@ -1710,7 +1704,7 @@ class RouteSetTest < ActiveSupport::TestCase
end
end
- assert_equal "/books/list.rss", url_for(set, { controller: "books", action: "list" })
+ assert_equal "/books/list.rss", url_for(set, controller: "books", action: "list")
assert_equal({controller: "books", action: "list"}, set.recognize_path("/books/list.rss"))
end
@@ -1722,10 +1716,10 @@ class RouteSetTest < ActiveSupport::TestCase
end
end
- assert_equal "/books/list.rss", url_for(set, { controller: "books", action: "list", format: "rss" })
- assert_equal "/books/list.xml", url_for(set, { controller: "books", action: "list", format: "xml" })
- assert_equal "/books/list", url_for(set, { controller: "books", action: "list" })
- assert_equal "/books", url_for(set, { controller: "books", action: "index" })
+ assert_equal "/books/list.rss", url_for(set, controller: "books", action: "list", format: "rss")
+ assert_equal "/books/list.xml", url_for(set, controller: "books", action: "list", format: "xml")
+ assert_equal "/books/list", url_for(set, controller: "books", action: "list")
+ assert_equal "/books", url_for(set, controller: "books", action: "index")
assert_equal({controller: "books", action: "list", format: "rss"}, set.recognize_path("/books/list.rss"))
assert_equal({controller: "books", action: "list", format: "xml"}, set.recognize_path("/books/list.xml"))
@@ -1736,9 +1730,9 @@ class RouteSetTest < ActiveSupport::TestCase
def test_slashes_are_implied
set.draw { ActiveSupport::Deprecation.silence { get("/:controller(/:action(/:id))") } }
- assert_equal "/content", url_for(set, { controller: "content", action: "index" })
- assert_equal "/content/list", url_for(set, { controller: "content", action: "list" })
- assert_equal "/content/show/1", url_for(set, { controller: "content", action: "show", id: "1" })
+ assert_equal "/content", url_for(set, controller: "content", action: "index")
+ assert_equal "/content/list", url_for(set, controller: "content", action: "list")
+ assert_equal "/content/show/1", url_for(set, controller: "content", action: "show", id: "1")
assert_equal({controller: "content", action: "index"}, set.recognize_path("/content"))
assert_equal({controller: "content", action: "index"}, set.recognize_path("/content/index"))
@@ -1767,15 +1761,15 @@ class RouteSetTest < ActiveSupport::TestCase
end
def test_default_route_should_omit_default_action
- assert_equal "/accounts", url_for(default_route_set, { controller: "accounts", action: "index" })
+ assert_equal "/accounts", url_for(default_route_set, controller: "accounts", action: "index")
end
def test_default_route_should_include_default_action_when_id_present
- assert_equal "/accounts/index/20", url_for(default_route_set, { controller: "accounts", action: "index", id: "20" })
+ assert_equal "/accounts/index/20", url_for(default_route_set, controller: "accounts", action: "index", id: "20")
end
def test_default_route_should_work_with_action_but_no_id
- assert_equal "/accounts/list_all", url_for(default_route_set, { controller: "accounts", action: "list_all" })
+ assert_equal "/accounts/list_all", url_for(default_route_set, controller: "accounts", action: "list_all")
end
def test_default_route_should_uri_escape_pluses
@@ -1790,31 +1784,31 @@ class RouteSetTest < ActiveSupport::TestCase
end
def test_build_empty_query_string
- assert_uri_equal "/foo", url_for(default_route_set, { controller: "foo" })
+ assert_uri_equal "/foo", url_for(default_route_set, controller: "foo")
end
def test_build_query_string_with_nil_value
- assert_uri_equal "/foo", url_for(default_route_set, { controller: "foo", x: nil })
+ assert_uri_equal "/foo", url_for(default_route_set, controller: "foo", x: nil)
end
def test_simple_build_query_string
- assert_uri_equal "/foo?x=1&y=2", url_for(default_route_set, { controller: "foo", x: "1", y: "2" })
+ assert_uri_equal "/foo?x=1&y=2", url_for(default_route_set, controller: "foo", x: "1", y: "2")
end
def test_convert_ints_build_query_string
- assert_uri_equal "/foo?x=1&y=2", url_for(default_route_set, { controller: "foo", x: 1, y: 2 })
+ assert_uri_equal "/foo?x=1&y=2", url_for(default_route_set, controller: "foo", x: 1, y: 2)
end
def test_escape_spaces_build_query_string
- assert_uri_equal "/foo?x=hello+world&y=goodbye+world", url_for(default_route_set, { controller: "foo", x: "hello world", y: "goodbye world" })
+ assert_uri_equal "/foo?x=hello+world&y=goodbye+world", url_for(default_route_set, controller: "foo", x: "hello world", y: "goodbye world")
end
def test_expand_array_build_query_string
- assert_uri_equal "/foo?x%5B%5D=1&x%5B%5D=2", url_for(default_route_set, { controller: "foo", x: [1, 2] })
+ assert_uri_equal "/foo?x%5B%5D=1&x%5B%5D=2", url_for(default_route_set, controller: "foo", x: [1, 2])
end
def test_escape_spaces_build_query_string_selected_keys
- assert_uri_equal "/foo?x=hello+world", url_for(default_route_set, { controller: "foo", x: "hello world" })
+ assert_uri_equal "/foo?x=hello+world", url_for(default_route_set, controller: "foo", x: "hello world")
end
def test_generate_with_default_params
@@ -1830,7 +1824,7 @@ class RouteSetTest < ActiveSupport::TestCase
end
end
- assert_equal "/ibocorp", url_for(set, { controller: "ibocorp", action: "show", page: 1 })
+ assert_equal "/ibocorp", url_for(set, controller: "ibocorp", action: "show", page: 1)
end
include ActionDispatch::RoutingVerbs
@@ -1876,11 +1870,11 @@ class RouteSetTest < ActiveSupport::TestCase
get URI("http://example.org/blog/2006/07/28")
assert_equal({controller: "blog", action: "show_date", year: "2006", month: "07", day: "28"}, controller.request.path_parameters)
- assert_equal("/blog/2006/07/25", controller.url_for({ day: 25, only_path: true }))
- assert_equal("/blog/2005", controller.url_for({ year: 2005, only_path: true }))
- assert_equal("/blog/show/123", controller.url_for({ action: "show" , id: 123, only_path: true }))
- assert_equal("/blog/2006", controller.url_for({ year: 2006, only_path: true }))
- assert_equal("/blog/2006", controller.url_for({ year: 2006, month: nil, only_path: true }))
+ assert_equal("/blog/2006/07/25", controller.url_for(day: 25, only_path: true))
+ assert_equal("/blog/2005", controller.url_for(year: 2005, only_path: true))
+ assert_equal("/blog/show/123", controller.url_for(action: "show" , id: 123, only_path: true))
+ assert_equal("/blog/2006", controller.url_for(year: 2006, only_path: true))
+ assert_equal("/blog/2006", controller.url_for(year: 2006, month: nil, only_path: true))
end
private
diff --git a/actionpack/test/controller/test_case_test.rb b/actionpack/test/controller/test_case_test.rb
index d369514119..45bc770e86 100644
--- a/actionpack/test/controller/test_case_test.rb
+++ b/actionpack/test/controller/test_case_test.rb
@@ -273,7 +273,7 @@ XML
end
def test_deprecated_process_with_flash
- assert_deprecated { process :set_flash, "GET", nil, nil, { "test" => "value" } }
+ assert_deprecated { process :set_flash, "GET", nil, nil, "test" => "value" }
assert_equal ">value<", flash["test"]
end
@@ -285,7 +285,7 @@ XML
end
def test_deprecated_process_with_flash_now
- assert_deprecated { process :set_flash_now, "GET", nil, nil, { "test_now" => "value_now" } }
+ assert_deprecated { process :set_flash_now, "GET", nil, nil, "test_now" => "value_now" }
assert_equal ">value_now<", flash["test_now"]
end
@@ -312,7 +312,7 @@ XML
end
def test_process_with_session_arg
- assert_deprecated { process :no_op, "GET", nil, { "string" => "value1", symbol: "value2" } }
+ assert_deprecated { process :no_op, "GET", nil, "string" => "value1", symbol: "value2" }
assert_equal "value1", session["string"]
assert_equal "value1", session[:string]
assert_equal "value2", session["symbol"]
@@ -330,7 +330,7 @@ XML
def test_deprecated_process_merges_session_arg
session[:foo] = "bar"
assert_deprecated {
- get :no_op, nil, { bar: "baz" }
+ get :no_op, nil, bar: "baz"
}
assert_equal "bar", session[:foo]
assert_equal "baz", session[:bar]
@@ -345,7 +345,7 @@ XML
def test_deprecated_merged_session_arg_is_retained_across_requests
assert_deprecated {
- get :no_op, nil, { foo: "bar" }
+ get :no_op, nil, foo: "bar"
}
assert_equal "bar", session[:foo]
get :no_op
@@ -455,9 +455,9 @@ XML
def test_assert_generates
assert_generates "controller/action/5", controller: "controller", action: "action", id: "5"
- assert_generates "controller/action/7", { id: "7" }, { controller: "controller", action: "action" }
- assert_generates "controller/action/5", { controller: "controller", action: "action", id: "5", name: "bob" }, {}, { name: "bob" }
- assert_generates "controller/action/7", { id: "7", name: "bob" }, { controller: "controller", action: "action" }, { name: "bob" }
+ assert_generates "controller/action/7", { id: "7" }, controller: "controller", action: "action"
+ assert_generates "controller/action/5", { controller: "controller", action: "action", id: "5", name: "bob" }, {}, name: "bob"
+ assert_generates "controller/action/7", { id: "7", name: "bob" }, { controller: "controller", action: "action" }, name: "bob"
assert_generates "controller/action/7", { id: "7" }, { controller: "controller", action: "action", name: "bob" }, {}
end
@@ -468,7 +468,7 @@ XML
def test_assert_routing_with_method
with_routing do |set|
set.draw { resources(:content) }
- assert_routing({ method: "post", path: "content" }, { controller: "content", action: "create" })
+ assert_routing({ method: "post", path: "content" }, controller: "content", action: "create")
end
end
@@ -487,7 +487,7 @@ XML
def test_assert_routing_with_glob
with_routing do |set|
set.draw { get("*path" => "pages#show") }
- assert_routing("/company/about", { controller: "pages", action: "show", path: "company/about" })
+ assert_routing("/company/about", controller: "pages", action: "show", path: "company/about")
end
end
diff --git a/actionpack/test/controller/url_for_test.rb b/actionpack/test/controller/url_for_test.rb
index 6b0dd0ac88..ad4acf3462 100644
--- a/actionpack/test/controller/url_for_test.rb
+++ b/actionpack/test/controller/url_for_test.rb
@@ -29,9 +29,9 @@ module AbstractController
self.default_url_options[:host] = "example.com"
}
- path = klass.new.fun_path({controller: :articles,
+ path = klass.new.fun_path(controller: :articles,
baz: "baz",
- zot: "zot"})
+ zot: "zot")
# :bar key isn't provided
assert_equal "/foo/zot", path
end
@@ -230,21 +230,21 @@ module AbstractController
add_host!
options = { trailing_slash: true,protocol: "https", controller: "foo", action: "bar", id: "33"}
assert_equal("https://www.basecamphq.com/foo/bar/33/", W.new.url_for(options) )
- assert_equal "https://www.basecamphq.com/foo/bar/33/?query=string", W.new.url_for(options.merge({query: "string"}))
+ assert_equal "https://www.basecamphq.com/foo/bar/33/?query=string", W.new.url_for(options.merge(query: "string"))
end
def test_trailing_slash_with_only_path
options = {controller: "foo", trailing_slash: true}
- assert_equal "/foo/", W.new.url_for(options.merge({only_path: true}))
- options.update({action: "bar", id: "33"})
- assert_equal "/foo/bar/33/", W.new.url_for(options.merge({only_path: true}))
- assert_equal "/foo/bar/33/?query=string", W.new.url_for(options.merge({query: "string",only_path: true}))
+ assert_equal "/foo/", W.new.url_for(options.merge(only_path: true))
+ options.update(action: "bar", id: "33")
+ assert_equal "/foo/bar/33/", W.new.url_for(options.merge(only_path: true))
+ assert_equal "/foo/bar/33/?query=string", W.new.url_for(options.merge(query: "string",only_path: true))
end
def test_trailing_slash_with_anchor
options = {trailing_slash: true, controller: "foo", action: "bar", id: "33", only_path: true, anchor: "chapter7"}
assert_equal "/foo/bar/33/#chapter7", W.new.url_for(options)
- assert_equal "/foo/bar/33/?query=string#chapter7", W.new.url_for(options.merge({query: "string"}))
+ assert_equal "/foo/bar/33/?query=string#chapter7", W.new.url_for(options.merge(query: "string"))
end
def test_trailing_slash_with_params
diff --git a/actionpack/test/controller/url_rewriter_test.rb b/actionpack/test/controller/url_rewriter_test.rb
index 5f481c1edb..81dc230929 100644
--- a/actionpack/test/controller/url_rewriter_test.rb
+++ b/actionpack/test/controller/url_rewriter_test.rb
@@ -81,10 +81,10 @@ class UrlRewriterTests < ActionController::TestCase
def test_trailing_slash
options = {controller: "foo", action: "bar", id: "3", only_path: true}
assert_equal "/foo/bar/3", @rewriter.rewrite(@routes, options)
- assert_equal "/foo/bar/3?query=string", @rewriter.rewrite(@routes, options.merge({query: "string"}))
- options.update({trailing_slash: true})
+ assert_equal "/foo/bar/3?query=string", @rewriter.rewrite(@routes, options.merge(query: "string"))
+ options.update(trailing_slash: true)
assert_equal "/foo/bar/3/", @rewriter.rewrite(@routes, options)
- options.update({query: "string"})
+ options.update(query: "string")
assert_equal "/foo/bar/3/?query=string", @rewriter.rewrite(@routes, options)
end
end
diff --git a/actionpack/test/controller/webservice_test.rb b/actionpack/test/controller/webservice_test.rb
index 671009c090..6f97a4b62e 100644
--- a/actionpack/test/controller/webservice_test.rb
+++ b/actionpack/test/controller/webservice_test.rb
@@ -103,7 +103,7 @@ class WebServiceTest < ActionDispatch::IntegrationTest
end
def content_length; get_header("rack.input").length; end
- end.new({ "rack.input" => StringIO.new('{"title":"JSON"}}'), "CONTENT_TYPE" => "application/json" })
+ end.new("rack.input" => StringIO.new('{"title":"JSON"}}'), "CONTENT_TYPE" => "application/json")
assert_raises(Interrupt) do
req.request_parameters
diff --git a/actionpack/test/dispatch/callbacks_test.rb b/actionpack/test/dispatch/callbacks_test.rb
index 300f7b7a16..ca3154e16e 100644
--- a/actionpack/test/dispatch/callbacks_test.rb
+++ b/actionpack/test/dispatch/callbacks_test.rb
@@ -57,7 +57,7 @@ class DispatcherTest < ActiveSupport::TestCase
def dispatch(&block)
ActionDispatch::Callbacks.new(block || DummyApp.new).call(
- {"rack.input" => StringIO.new("")}
+ "rack.input" => StringIO.new("")
)
end
diff --git a/actionpack/test/dispatch/executor_test.rb b/actionpack/test/dispatch/executor_test.rb
index 1d5a554903..0b4e0849c3 100644
--- a/actionpack/test/dispatch/executor_test.rb
+++ b/actionpack/test/dispatch/executor_test.rb
@@ -120,7 +120,7 @@ class ExecutorTest < ActiveSupport::TestCase
private
def call_and_return_body(&block)
app = middleware(block || proc { [200, {}, "response"] })
- _, _, body = app.call({"rack.input" => StringIO.new("")})
+ _, _, body = app.call("rack.input" => StringIO.new(""))
body
end
diff --git a/actionpack/test/dispatch/rack_cache_test.rb b/actionpack/test/dispatch/rack_cache_test.rb
index e421cbdbce..d7bb90abbf 100644
--- a/actionpack/test/dispatch/rack_cache_test.rb
+++ b/actionpack/test/dispatch/rack_cache_test.rb
@@ -12,7 +12,7 @@ class RackCacheMetaStoreTest < ActiveSupport::TestCase
end
test "stuff is deep duped" do
- @store.write(:foo, { bar: :original })
+ @store.write(:foo, bar: :original)
hash = @store.read(:foo)
hash[:bar] = :changed
hash = @store.read(:foo)
diff --git a/actionpack/test/dispatch/reloader_test.rb b/actionpack/test/dispatch/reloader_test.rb
index 5dd3414958..761237d5dc 100644
--- a/actionpack/test/dispatch/reloader_test.rb
+++ b/actionpack/test/dispatch/reloader_test.rb
@@ -198,6 +198,6 @@ class ReloaderTest < ActiveSupport::TestCase
@response ||= "response"
@reloader ||= Reloader.new(block || proc {[200, {}, @response]}, x)
- @reloader.call({"rack.input" => StringIO.new("")})[2]
+ @reloader.call("rack.input" => StringIO.new(""))[2]
end
end
diff --git a/actionpack/test/dispatch/request/json_params_parsing_test.rb b/actionpack/test/dispatch/request/json_params_parsing_test.rb
index 20e16dc0c2..e24b1e12e3 100644
--- a/actionpack/test/dispatch/request/json_params_parsing_test.rb
+++ b/actionpack/test/dispatch/request/json_params_parsing_test.rb
@@ -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\",null]}", "CONTENT_TYPE" => "application/json"
)
assert_parses(
{"person" => []},
- "{\"person\":[null, null]}", { "CONTENT_TYPE" => "application/json" }
+ "{\"person\":[null, null]}", "CONTENT_TYPE" => "application/json"
)
end
@@ -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
@@ -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
@@ -186,7 +186,7 @@ class RootLessJSONParamsParsingTest < ActionDispatch::IntegrationTest
post "/parse", params: actual, headers: headers
assert_response :ok
assert_equal(expected, UsersController.last_request_parameters)
- assert_equal(expected.merge({"action" => "parse"}), UsersController.last_parameters)
+ assert_equal(expected.merge("action" => "parse"), UsersController.last_parameters)
end
end
diff --git a/actionpack/test/dispatch/response_test.rb b/actionpack/test/dispatch/response_test.rb
index 1efcd9e97f..d539092244 100644
--- a/actionpack/test/dispatch/response_test.rb
+++ b/actionpack/test/dispatch/response_test.rb
@@ -291,7 +291,7 @@ class ResponseTest < ActiveSupport::TestCase
test "read content type with default charset utf-8" do
original = ActionDispatch::Response.default_charset
begin
- resp = ActionDispatch::Response.new(200, { "Content-Type" => "text/xml" })
+ resp = ActionDispatch::Response.new(200, "Content-Type" => "text/xml")
assert_equal("utf-8", resp.charset)
ensure
ActionDispatch::Response.default_charset = original
@@ -302,7 +302,7 @@ class ResponseTest < ActiveSupport::TestCase
original = ActionDispatch::Response.default_charset
begin
ActionDispatch::Response.default_charset = "utf-16"
- resp = ActionDispatch::Response.new(200, { "Content-Type" => "text/xml" })
+ resp = ActionDispatch::Response.new(200, "Content-Type" => "text/xml")
assert_equal("utf-16", resp.charset)
ensure
ActionDispatch::Response.default_charset = original
diff --git a/actionpack/test/dispatch/routing_assertions_test.rb b/actionpack/test/dispatch/routing_assertions_test.rb
index 1e77c7311e..1f8ce059d1 100644
--- a/actionpack/test/dispatch/routing_assertions_test.rb
+++ b/actionpack/test/dispatch/routing_assertions_test.rb
@@ -27,16 +27,16 @@ class RoutingAssertionsTest < ActionController::TestCase
end
def test_assert_generates
- assert_generates("/articles", { controller: "articles", action: "index" })
- assert_generates("/articles/1", { controller: "articles", action: "show", id: "1" })
+ assert_generates("/articles", controller: "articles", action: "index")
+ assert_generates("/articles/1", controller: "articles", action: "show", id: "1")
end
def test_assert_generates_with_defaults
- assert_generates("/articles/1/edit", { controller: "articles", action: "edit" }, { id: "1" })
+ assert_generates("/articles/1/edit", { controller: "articles", action: "edit" }, id: "1")
end
def test_assert_generates_with_extras
- assert_generates("/articles", { controller: "articles", action: "index", page: "1" }, {}, { page: "1" })
+ assert_generates("/articles", { controller: "articles", action: "index", page: "1" }, {}, page: "1")
end
def test_assert_recognizes
@@ -45,12 +45,12 @@ class RoutingAssertionsTest < ActionController::TestCase
end
def test_assert_recognizes_with_extras
- assert_recognizes({ controller: "articles", action: "index", page: "1" }, "/articles", { page: "1" })
+ assert_recognizes({ controller: "articles", action: "index", page: "1" }, "/articles", page: "1")
end
def test_assert_recognizes_with_method
- assert_recognizes({ controller: "articles", action: "create" }, { path: "/articles", method: :post })
- assert_recognizes({ controller: "articles", action: "update", id: "1" }, { path: "/articles/1", method: :put })
+ assert_recognizes({ controller: "articles", action: "create" }, path: "/articles", method: :post)
+ assert_recognizes({ controller: "articles", action: "update", id: "1" }, path: "/articles/1", method: :put)
end
def test_assert_recognizes_with_hash_constraint
@@ -69,9 +69,9 @@ class RoutingAssertionsTest < ActionController::TestCase
def test_assert_recognizes_with_query_constraint
assert_raise(Assertion) do
- assert_recognizes({ controller: "query_articles", action: "index", use_query: "false" }, "/query/articles", { use_query: "false" })
+ assert_recognizes({ controller: "query_articles", action: "index", use_query: "false" }, "/query/articles", use_query: "false")
end
- assert_recognizes({ controller: "query_articles", action: "index", use_query: "true" }, "/query/articles", { use_query: "true" })
+ assert_recognizes({ controller: "query_articles", action: "index", use_query: "true" }, "/query/articles", use_query: "true")
end
def test_assert_recognizes_raises_message
@@ -95,25 +95,25 @@ class RoutingAssertionsTest < ActionController::TestCase
end
def test_assert_routing_with_defaults
- assert_routing("/articles/1/edit", { controller: "articles", action: "edit", id: "1" }, { id: "1" })
+ assert_routing("/articles/1/edit", { controller: "articles", action: "edit", id: "1" }, id: "1")
end
def test_assert_routing_with_extras
- assert_routing("/articles", { controller: "articles", action: "index", page: "1" }, { }, { page: "1" })
+ assert_routing("/articles", { controller: "articles", action: "index", page: "1" }, { }, page: "1")
end
def test_assert_routing_with_hash_constraint
assert_raise(Assertion) do
- assert_routing("http://test.host/secure/articles", { controller: "secure_articles", action: "index" })
+ assert_routing("http://test.host/secure/articles", controller: "secure_articles", action: "index")
end
- assert_routing("https://test.host/secure/articles", { controller: "secure_articles", action: "index", protocol: "https://" })
+ assert_routing("https://test.host/secure/articles", controller: "secure_articles", action: "index", protocol: "https://")
end
def test_assert_routing_with_block_constraint
assert_raise(Assertion) do
- assert_routing("http://test.host/block/articles", { controller: "block_articles", action: "index" })
+ assert_routing("http://test.host/block/articles", controller: "block_articles", action: "index")
end
- assert_routing("https://test.host/block/articles", { controller: "block_articles", action: "index" })
+ assert_routing("https://test.host/block/articles", controller: "block_articles", action: "index")
end
def test_with_routing
@@ -124,7 +124,7 @@ class RoutingAssertionsTest < ActionController::TestCase
assert_routing("/artikel", controller: "articles", action: "index")
assert_raise(Assertion) do
- assert_routing("/articles", { controller: "articles", action: "index" })
+ assert_routing("/articles", controller: "articles", action: "index")
end
end
end
diff --git a/actionpack/test/journey/route_test.rb b/actionpack/test/journey/route_test.rb
index 5364f9de81..cce5c2ae37 100644
--- a/actionpack/test/journey/route_test.rb
+++ b/actionpack/test/journey/route_test.rb
@@ -35,57 +35,53 @@ module ActionDispatch
def test_ip_address
path = Path::Pattern.from_string "/messages/:id(.:format)"
route = Route.build("name", nil, path, {ip: "192.168.1.1"}, [],
- { controller: "foo", action: "bar" })
+ controller: "foo", action: "bar")
assert_equal "192.168.1.1", route.ip
end
def test_default_ip
path = Path::Pattern.from_string "/messages/:id(.:format)"
route = Route.build("name", nil, path, {}, [],
- { controller: "foo", action: "bar" })
+ controller: "foo", action: "bar")
assert_equal(//, route.ip)
end
def test_format_with_star
path = Path::Pattern.from_string "/:controller/*extra"
route = Route.build("name", nil, path, {}, [],
- { controller: "foo", action: "bar" })
- assert_equal "/foo/himom", route.format({
- controller: "foo",
- extra: "himom",
- })
+ controller: "foo", action: "bar")
+ assert_equal "/foo/himom", route.format( controller: "foo",
+ extra: "himom")
end
def test_connects_all_match
path = Path::Pattern.from_string "/:controller(/:action(/:id(.:format)))"
- route = Route.build("name", nil, path, {action: "bar"}, [], { controller: "foo" })
+ route = Route.build("name", nil, path, {action: "bar"}, [], controller: "foo")
- assert_equal "/foo/bar/10", route.format({
- controller: "foo",
+ assert_equal "/foo/bar/10", route.format( controller: "foo",
action: "bar",
- id: 10
- })
+ id: 10)
end
def test_extras_are_not_included_if_optional
path = Path::Pattern.from_string "/page/:id(/:action)"
- route = Route.build("name", nil, path, { }, [], { action: "show" })
+ route = Route.build("name", nil, path, { }, [], action: "show")
- assert_equal "/page/10", route.format({ id: 10 })
+ assert_equal "/page/10", route.format(id: 10)
end
def test_extras_are_not_included_if_optional_with_parameter
path = Path::Pattern.from_string "(/sections/:section)/pages/:id"
- route = Route.build("name", nil, path, { }, [], { action: "show" })
+ route = Route.build("name", nil, path, { }, [], action: "show")
- assert_equal "/pages/10", route.format({id: 10})
+ assert_equal "/pages/10", route.format(id: 10)
end
def test_extras_are_not_included_if_optional_parameter_is_nil
path = Path::Pattern.from_string "(/sections/:section)/pages/:id"
- route = Route.build("name", nil, path, { }, [], { action: "show" })
+ route = Route.build("name", nil, path, { }, [], action: "show")
- assert_equal "/pages/10", route.format({id: 10, section: nil})
+ assert_equal "/pages/10", route.format(id: 10, section: nil)
end
def test_score
diff --git a/actionpack/test/journey/router_test.rb b/actionpack/test/journey/router_test.rb
index 97d3bc9845..83cd999352 100644
--- a/actionpack/test/journey/router_test.rb
+++ b/actionpack/test/journey/router_test.rb
@@ -109,7 +109,7 @@ module ActionDispatch
def test_X_Cascade
get "/messages(.:format)", to: "foo#bar"
- resp = router.serve(rails_env({ "REQUEST_METHOD" => "GET", "PATH_INFO" => "/lol" }))
+ resp = router.serve(rails_env("REQUEST_METHOD" => "GET", "PATH_INFO" => "/lol"))
assert_equal ["Not Found"], resp.last
assert_equal "pass", resp[1]["X-Cascade"]
assert_equal 404, resp.first
@@ -184,14 +184,14 @@ module ActionDispatch
def test_required_part_in_recall
get "/messages/:a/:b", to: "foo#bar"
- path, _ = @formatter.generate(nil, { controller: "foo", action: "bar", a: "a" }, { b: "b" })
+ path, _ = @formatter.generate(nil, { controller: "foo", action: "bar", a: "a" }, b: "b")
assert_equal "/messages/a/b", path
end
def test_splat_in_recall
get "/*path", to: "foo#bar"
- path, _ = @formatter.generate(nil, { controller: "foo", action: "bar" }, { path: "b" })
+ path, _ = @formatter.generate(nil, { controller: "foo", action: "bar" }, path: "b")
assert_equal "/b", path
end
@@ -199,7 +199,7 @@ module ActionDispatch
get "/messages/:action(/:id(.:format))", to: "foo#bar"
get "/messages/:id(.:format)", to: "bar#baz"
- path, _ = @formatter.generate(nil, { controller: "foo", id: 10 }, { action: "index" })
+ path, _ = @formatter.generate(nil, { controller: "foo", id: 10 }, action: "index")
assert_equal "/messages/index/10", path
end
@@ -312,7 +312,7 @@ module ActionDispatch
path, params = @formatter.generate(
nil,
{controller: "tasks", id: 10},
- {action: "index"})
+ action: "index")
assert_equal "/tasks/index/10", path
assert_equal({}, params)
end
@@ -323,7 +323,7 @@ module ActionDispatch
path, params = @formatter.generate(
"tasks",
{controller: "tasks"},
- {controller: "tasks", action: "index"})
+ controller: "tasks", action: "index")
assert_equal "/tasks", path
assert_equal({}, params)
end
@@ -372,7 +372,7 @@ module ActionDispatch
end
def test_namespaced_controller
- get "/:controller(/:action(/:id))", { controller: /.+?/ }
+ get "/:controller(/:action(/:id))", controller: /.+?/
route = @routes.first
env = rails_env "PATH_INFO" => "/admin/users/show/10"