aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/controller
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2016-08-16 04:30:11 -0300
committerRafael Mendonça França <rafaelmfranca@gmail.com>2016-08-16 04:30:11 -0300
commit55f9b8129a50206513264824abb44088230793c2 (patch)
treeff2f01cabfc7e74b0bd831c2272a5517e4e81e99 /actionpack/test/controller
parentd0bdd74d7f6fae3d69b3681d5bc2d5ef6f55a0f8 (diff)
downloadrails-55f9b8129a50206513264824abb44088230793c2.tar.gz
rails-55f9b8129a50206513264824abb44088230793c2.tar.bz2
rails-55f9b8129a50206513264824abb44088230793c2.zip
Add three new rubocop rules
Style/SpaceBeforeBlockBraces Style/SpaceInsideBlockBraces Style/SpaceInsideHashLiteralBraces Fix all violations in the repository.
Diffstat (limited to 'actionpack/test/controller')
-rw-r--r--actionpack/test/controller/action_pack_assertions_test.rb2
-rw-r--r--actionpack/test/controller/api/params_wrapper_test.rb2
-rw-r--r--actionpack/test/controller/caching_test.rb6
-rw-r--r--actionpack/test/controller/default_url_options_with_before_action_test.rb2
-rw-r--r--actionpack/test/controller/filters_test.rb8
-rw-r--r--actionpack/test/controller/flash_hash_test.rb28
-rw-r--r--actionpack/test/controller/flash_test.rb8
-rw-r--r--actionpack/test/controller/http_digest_authentication_test.rb4
-rw-r--r--actionpack/test/controller/http_token_authentication_test.rb6
-rw-r--r--actionpack/test/controller/integration_test.rb32
-rw-r--r--actionpack/test/controller/live_stream_test.rb4
-rw-r--r--actionpack/test/controller/log_subscriber_test.rb2
-rw-r--r--actionpack/test/controller/mime/respond_to_test.rb16
-rw-r--r--actionpack/test/controller/new_base/render_file_test.rb2
-rw-r--r--actionpack/test/controller/parameter_encoding_test.rb10
-rw-r--r--actionpack/test/controller/parameters/accessors_test.rb2
-rw-r--r--actionpack/test/controller/parameters/dup_test.rb2
-rw-r--r--actionpack/test/controller/parameters/mutators_test.rb2
-rw-r--r--actionpack/test/controller/parameters/nested_parameters_permit_test.rb4
-rw-r--r--actionpack/test/controller/parameters/parameters_permit_test.rb18
-rw-r--r--actionpack/test/controller/params_wrapper_test.rb8
-rw-r--r--actionpack/test/controller/redirect_test.rb4
-rw-r--r--actionpack/test/controller/render_json_test.rb2
-rw-r--r--actionpack/test/controller/render_test.rb2
-rw-r--r--actionpack/test/controller/request_forgery_protection_test.rb32
-rw-r--r--actionpack/test/controller/required_params_test.rb4
-rw-r--r--actionpack/test/controller/resources_test.rb64
-rw-r--r--actionpack/test/controller/routing_test.rb280
-rw-r--r--actionpack/test/controller/send_file_test.rb2
-rw-r--r--actionpack/test/controller/test_case_test.rb40
-rw-r--r--actionpack/test/controller/url_for_integration_test.rb8
-rw-r--r--actionpack/test/controller/url_for_test.rb46
-rw-r--r--actionpack/test/controller/url_rewriter_test.rb2
33 files changed, 327 insertions, 327 deletions
diff --git a/actionpack/test/controller/action_pack_assertions_test.rb b/actionpack/test/controller/action_pack_assertions_test.rb
index 55b4c1e6a6..b08f1f1707 100644
--- a/actionpack/test/controller/action_pack_assertions_test.rb
+++ b/actionpack/test/controller/action_pack_assertions_test.rb
@@ -165,7 +165,7 @@ class ActionPackAssertionsControllerTest < ActionController::TestCase
def test_string_constraint
with_routing do |set|
set.draw do
- get "photos", to: "action_pack_assertions#nothing", constraints: {subdomain: "admin"}
+ get "photos", to: "action_pack_assertions#nothing", constraints: { subdomain: "admin" }
end
end
end
diff --git a/actionpack/test/controller/api/params_wrapper_test.rb b/actionpack/test/controller/api/params_wrapper_test.rb
index cdf5acecae..a1da852040 100644
--- a/actionpack/test/controller/api/params_wrapper_test.rb
+++ b/actionpack/test/controller/api/params_wrapper_test.rb
@@ -20,7 +20,7 @@ class ParamsWrapperForApiTest < ActionController::TestCase
@request.env["CONTENT_TYPE"] = "application/json"
post :test, params: { "username" => "sikachu" }
- expected = { "username" => "sikachu", "person" => { "username" => "sikachu" }}
+ expected = { "username" => "sikachu", "person" => { "username" => "sikachu" } }
assert_equal expected, @controller.last_parameters
end
end
diff --git a/actionpack/test/controller/caching_test.rb b/actionpack/test/controller/caching_test.rb
index 5f4857c553..18490c7d73 100644
--- a/actionpack/test/controller/caching_test.rb
+++ b/actionpack/test/controller/caching_test.rb
@@ -49,7 +49,7 @@ class FragmentCachingTest < ActionController::TestCase
@controller = FragmentCachingTestController.new
@controller.perform_caching = true
@controller.cache_store = @store
- @params = {controller: "posts", action: "index"}
+ @params = { controller: "posts", action: "index" }
@controller.params = @params
@controller.request = @request
@controller.response = @response
@@ -324,7 +324,7 @@ class CacheHelperOutputBufferTest < ActionController::TestCase
cache_helper.stub :output_buffer, output_buffer do
assert_called_with cache_helper, :output_buffer=, [output_buffer.class.new(output_buffer)] do
assert_nothing_raised do
- cache_helper.send :fragment_for, "Test fragment name", "Test fragment", &Proc.new{ nil }
+ cache_helper.send :fragment_for, "Test fragment name", "Test fragment", &Proc.new { nil }
end
end
end
@@ -345,7 +345,7 @@ class CacheHelperOutputBufferTest < ActionController::TestCase
cache_helper.stub :output_buffer, output_buffer do
assert_called_with cache_helper, :output_buffer=, [output_buffer.class.new(output_buffer)] do
assert_nothing_raised do
- cache_helper.send :fragment_for, "Test fragment name", "Test fragment", &Proc.new{ nil }
+ cache_helper.send :fragment_for, "Test fragment name", "Test fragment", &Proc.new { nil }
end
end
end
diff --git a/actionpack/test/controller/default_url_options_with_before_action_test.rb b/actionpack/test/controller/default_url_options_with_before_action_test.rb
index 703f9f1fde..e3fe7a6495 100644
--- a/actionpack/test/controller/default_url_options_with_before_action_test.rb
+++ b/actionpack/test/controller/default_url_options_with_before_action_test.rb
@@ -13,7 +13,7 @@ class ControllerWithBeforeActionAndDefaultUrlOptions < ActionController::Base
end
def default_url_options
- {locale: "de"}
+ { locale: "de" }
end
end
diff --git a/actionpack/test/controller/filters_test.rb b/actionpack/test/controller/filters_test.rb
index 237711452a..e0987070a3 100644
--- a/actionpack/test/controller/filters_test.rb
+++ b/actionpack/test/controller/filters_test.rb
@@ -174,11 +174,11 @@ class FilterTest < ActionController::TestCase
end
class OnlyConditionProcController < ConditionalFilterController
- before_action(only: :show) {|c| c.instance_variable_set(:"@ran_proc_action", true) }
+ before_action(only: :show) { |c| c.instance_variable_set(:"@ran_proc_action", true) }
end
class ExceptConditionProcController < ConditionalFilterController
- before_action(except: :show_without_action) {|c| c.instance_variable_set(:"@ran_proc_action", true) }
+ before_action(except: :show_without_action) { |c| c.instance_variable_set(:"@ran_proc_action", true) }
end
class ConditionalClassFilter
@@ -194,11 +194,11 @@ class FilterTest < ActionController::TestCase
end
class AnomolousYetValidConditionController < ConditionalFilterController
- before_action(ConditionalClassFilter, :ensure_login, Proc.new {|c| c.instance_variable_set(:"@ran_proc_action1", true)}, except: :show_without_action) { |c| c.instance_variable_set(:"@ran_proc_action2", true)}
+ before_action(ConditionalClassFilter, :ensure_login, Proc.new { |c| c.instance_variable_set(:"@ran_proc_action1", true) }, except: :show_without_action) { |c| c.instance_variable_set(:"@ran_proc_action2", true) }
end
class OnlyConditionalOptionsFilter < ConditionalFilterController
- before_action :ensure_login, only: :index, if: Proc.new {|c| c.instance_variable_set(:"@ran_conditional_index_proc", true) }
+ before_action :ensure_login, only: :index, if: Proc.new { |c| c.instance_variable_set(:"@ran_conditional_index_proc", true) }
end
class ConditionalOptionsFilter < ConditionalFilterController
diff --git a/actionpack/test/controller/flash_hash_test.rb b/actionpack/test/controller/flash_hash_test.rb
index 16651a3fd7..32f0db71f5 100644
--- a/actionpack/test/controller/flash_hash_test.rb
+++ b/actionpack/test/controller/flash_hash_test.rb
@@ -48,11 +48,11 @@ module ActionDispatch
def test_to_hash
@hash["foo"] = "bar"
- assert_equal({"foo" => "bar"}, @hash.to_hash)
+ assert_equal({ "foo" => "bar" }, @hash.to_hash)
@hash.to_hash["zomg"] = "aaron"
assert !@hash.key?("zomg")
- assert_equal({"foo" => "bar"}, @hash.to_hash)
+ assert_equal({ "foo" => "bar" }, @hash.to_hash)
end
def test_to_session_value
@@ -74,7 +74,7 @@ module ActionDispatch
rails_3_2_cookie = "BAh7B0kiD3Nlc3Npb25faWQGOgZFRkkiJWY4ZTFiODE1MmJhNzYwOWMyOGJiYjE3ZWM5MjYzYmE3BjsAVEkiCmZsYXNoBjsARm86JUFjdGlvbkRpc3BhdGNoOjpGbGFzaDo6Rmxhc2hIYXNoCToKQHVzZWRvOghTZXQGOgpAaGFzaHsGSSINZmFyZXdlbGwGOwBUVDoMQGNsb3NlZEY6DUBmbGFzaGVzewdJIg1ncmVldGluZwY7AFRJIgpIZWxsbwY7AFRJIg1mYXJld2VsbAY7AFRJIgxHb29kYnllBjsAVDoJQG5vdzA="
session = Marshal.load(Base64.decode64(rails_3_2_cookie))
hash = Flash::FlashHash.from_session_value(session["flash"])
- assert_equal({"greeting" => "Hello"}, hash.to_hash)
+ assert_equal({ "greeting" => "Hello" }, hash.to_hash)
assert_equal(nil, hash.to_session_value)
end
@@ -83,7 +83,7 @@ module ActionDispatch
session = ActionDispatch::Cookies::JsonSerializer.load(decrypted_data)
hash = Flash::FlashHash.from_session_value(session["flash"])
- assert_equal({"greeting" => "Hello"}, hash.to_hash)
+ assert_equal({ "greeting" => "Hello" }, hash.to_hash)
assert_equal(nil, hash.to_session_value)
assert_equal "Hello", hash[:greeting]
assert_equal "Hello", hash["greeting"]
@@ -112,7 +112,7 @@ module ActionDispatch
def test_replace
@hash["hello"] = "world"
@hash.replace("omg" => "aaron")
- assert_equal({"omg" => "aaron"}, @hash.to_hash)
+ assert_equal({ "omg" => "aaron" }, @hash.to_hash)
end
def test_discard_no_args
@@ -129,14 +129,14 @@ module ActionDispatch
@hash.discard "hello"
@hash.sweep
- assert_equal({"omg" => "world"}, @hash.to_hash)
+ assert_equal({ "omg" => "world" }, @hash.to_hash)
end
def test_keep_sweep
@hash["hello"] = "world"
@hash.sweep
- assert_equal({"hello" => "world"}, @hash.to_hash)
+ assert_equal({ "hello" => "world" }, @hash.to_hash)
end
def test_update_sweep
@@ -144,7 +144,7 @@ module ActionDispatch
@hash.update("hi" => "mom")
@hash.sweep
- assert_equal({"hello" => "world", "hi" => "mom"}, @hash.to_hash)
+ assert_equal({ "hello" => "world", "hi" => "mom" }, @hash.to_hash)
end
def test_update_delete_sweep
@@ -153,7 +153,7 @@ module ActionDispatch
@hash.update("hello" => "mom")
@hash.sweep
- assert_equal({"hello" => "mom"}, @hash.to_hash)
+ assert_equal({ "hello" => "mom" }, @hash.to_hash)
end
def test_delete_sweep
@@ -162,7 +162,7 @@ module ActionDispatch
@hash.delete "hi"
@hash.sweep
- assert_equal({"hello" => "world"}, @hash.to_hash)
+ assert_equal({ "hello" => "world" }, @hash.to_hash)
end
def test_clear_sweep
@@ -178,7 +178,7 @@ module ActionDispatch
@hash.replace("hi" => "mom")
@hash.sweep
- assert_equal({"hi" => "mom"}, @hash.to_hash)
+ assert_equal({ "hi" => "mom" }, @hash.to_hash)
end
def test_discard_then_add
@@ -188,7 +188,7 @@ module ActionDispatch
@hash["hello"] = "world"
@hash.sweep
- assert_equal({"omg" => "world", "hello" => "world"}, @hash.to_hash)
+ assert_equal({ "omg" => "world", "hello" => "world" }, @hash.to_hash)
end
def test_keep_all_sweep
@@ -198,14 +198,14 @@ module ActionDispatch
@hash.keep
@hash.sweep
- assert_equal({"omg" => "world", "hello" => "world"}, @hash.to_hash)
+ assert_equal({ "omg" => "world", "hello" => "world" }, @hash.to_hash)
end
def test_double_sweep
@hash["hello"] = "world"
@hash.sweep
- assert_equal({"hello" => "world"}, @hash.to_hash)
+ assert_equal({ "hello" => "world" }, @hash.to_hash)
@hash.sweep
assert_equal({}, @hash.to_hash)
diff --git a/actionpack/test/controller/flash_test.rb b/actionpack/test/controller/flash_test.rb
index 4e046b2fc8..cabbe2d608 100644
--- a/actionpack/test/controller/flash_test.rb
+++ b/actionpack/test/controller/flash_test.rb
@@ -176,13 +176,13 @@ class FlashTest < ActionController::TestCase
assert_equal(:foo_indeed, flash.discard(:foo)) # valid key passed
assert_nil flash.discard(:unknown) # non existent key passed
- assert_equal({"foo" => :foo_indeed, "bar" => :bar_indeed}, flash.discard().to_hash) # nothing passed
- assert_equal({"foo" => :foo_indeed, "bar" => :bar_indeed}, flash.discard(nil).to_hash) # nothing passed
+ assert_equal({ "foo" => :foo_indeed, "bar" => :bar_indeed }, flash.discard().to_hash) # nothing passed
+ assert_equal({ "foo" => :foo_indeed, "bar" => :bar_indeed }, flash.discard(nil).to_hash) # nothing passed
assert_equal(:foo_indeed, flash.keep(:foo)) # valid key passed
assert_nil flash.keep(:unknown) # non existent key passed
- assert_equal({"foo" => :foo_indeed, "bar" => :bar_indeed}, flash.keep().to_hash) # nothing passed
- assert_equal({"foo" => :foo_indeed, "bar" => :bar_indeed}, flash.keep(nil).to_hash) # nothing passed
+ assert_equal({ "foo" => :foo_indeed, "bar" => :bar_indeed }, flash.keep().to_hash) # nothing passed
+ assert_equal({ "foo" => :foo_indeed, "bar" => :bar_indeed }, flash.keep(nil).to_hash) # nothing passed
end
def test_redirect_to_with_alert
diff --git a/actionpack/test/controller/http_digest_authentication_test.rb b/actionpack/test/controller/http_digest_authentication_test.rb
index 5e9b801f8b..343b7b643d 100644
--- a/actionpack/test/controller/http_digest_authentication_test.rb
+++ b/actionpack/test/controller/http_digest_authentication_test.rb
@@ -7,7 +7,7 @@ class HttpDigestAuthenticationTest < ActionController::TestCase
before_action :authenticate_with_request, only: :display
USERS = { "lifo" => "world", "pretty" => "please",
- "dhh" => ::Digest::MD5::hexdigest(["dhh","SuperSecret","secret"].join(":"))}
+ "dhh" => ::Digest::MD5::hexdigest(["dhh","SuperSecret","secret"].join(":")) }
def index
render plain: "Hello Secret"
@@ -199,7 +199,7 @@ class HttpDigestAuthenticationTest < ActionController::TestCase
test "validate_digest_response should fail with nil returning password_procedure" do
@request.env["HTTP_AUTHORIZATION"] = encode_credentials(username: nil, password: nil)
- assert !ActionController::HttpAuthentication::Digest.validate_digest_response(@request, "SuperSecret"){nil}
+ assert !ActionController::HttpAuthentication::Digest.validate_digest_response(@request, "SuperSecret") { nil }
end
test "authentication request with request-uri ending in '/'" do
diff --git a/actionpack/test/controller/http_token_authentication_test.rb b/actionpack/test/controller/http_token_authentication_test.rb
index b7a4c550d7..3842136682 100644
--- a/actionpack/test/controller/http_token_authentication_test.rb
+++ b/actionpack/test/controller/http_token_authentication_test.rb
@@ -156,10 +156,10 @@ class HttpTokenAuthenticationTest < ActionController::TestCase
test "token_and_options returns correct token with nounce option" do
token = "rcHu+HzSFw89Ypyhn/896A="
- nonce_hash = {nonce: "123abc"}
+ nonce_hash = { nonce: "123abc" }
actual = ActionController::HttpAuthentication::Token.token_and_options(sample_request(token, nonce_hash))
expected_token = token
- expected_nonce = {"nonce" => nonce_hash[:nonce]}
+ expected_nonce = { "nonce" => nonce_hash[:nonce] }
assert_equal(expected_token, actual.first)
assert_equal(expected_nonce, actual.last)
end
@@ -190,7 +190,7 @@ class HttpTokenAuthenticationTest < ActionController::TestCase
private
- def sample_request(token, options = {nonce: "def"})
+ def sample_request(token, options = { nonce: "def" })
authorization = options.inject([%{Token token="#{token}"}]) do |arr, (k, v)|
arr << "#{k}=\"#{v}\""
end.join(", ")
diff --git a/actionpack/test/controller/integration_test.rb b/actionpack/test/controller/integration_test.rb
index 4abbccfbe5..9044eff801 100644
--- a/actionpack/test/controller/integration_test.rb
+++ b/actionpack/test/controller/integration_test.rb
@@ -4,7 +4,7 @@ require "rails/engine"
class SessionTest < ActiveSupport::TestCase
StubApp = lambda { |env|
- [200, {"Content-Type" => "text/html", "Content-Length" => "13"}, ["Hello, World!"]]
+ [200, { "Content-Type" => "text/html", "Content-Length" => "13" }, ["Hello, World!"]]
}
def setup
@@ -32,7 +32,7 @@ class SessionTest < ActiveSupport::TestCase
end
def test_request_via_redirect_uses_given_method
- path = "/somepath"; args = {id: "1"}; headers = {"X-Test-Header" => "testvalue"}
+ path = "/somepath"; args = { id: "1" }; headers = { "X-Test-Header" => "testvalue" }
assert_called_with @session, :process, [:put, path, params: args, headers: headers] do
@session.stub :redirect?, false do
assert_deprecated { @session.request_via_redirect(:put, path, params: args, headers: headers) }
@@ -50,17 +50,17 @@ class SessionTest < ActiveSupport::TestCase
end
def test_request_via_redirect_follows_redirects
- path = "/somepath"; args = {id: "1"}; headers = {"X-Test-Header" => "testvalue"}
+ path = "/somepath"; args = { id: "1" }; headers = { "X-Test-Header" => "testvalue" }
value_series = [true, true, false]
assert_called @session, :follow_redirect!, times: 2 do
- @session.stub :redirect?, ->{ value_series.shift } do
+ @session.stub :redirect?, -> { value_series.shift } do
assert_deprecated { @session.request_via_redirect(:get, path, params: args, headers: headers) }
end
end
end
def test_request_via_redirect_returns_status
- path = "/somepath"; args = {id: "1"}; headers = {"X-Test-Header" => "testvalue"}
+ path = "/somepath"; args = { id: "1" }; headers = { "X-Test-Header" => "testvalue" }
@session.stub :redirect?, false do
@session.stub :status, 200 do
assert_deprecated do
@@ -466,7 +466,7 @@ class IntegrationProcessTest < ActionDispatch::IntegrationTest
def test_get_xml_rss_atom
%w[ application/xml application/rss+xml application/atom+xml ].each do |mime_string|
with_test_route_set do
- get "/get", headers: {"HTTP_ACCEPT" => mime_string}
+ get "/get", headers: { "HTTP_ACCEPT" => mime_string }
assert_equal 200, status
assert_equal "OK", status_message
assert_response 200
@@ -503,7 +503,7 @@ class IntegrationProcessTest < ActionDispatch::IntegrationTest
self.cookies["cookie_2"] = "oatmeal"
get "/cookie_monster"
assert_equal "cookie_1=; path=/\ncookie_3=chocolate; path=/", headers["Set-Cookie"]
- assert_equal({"cookie_1"=>"", "cookie_2"=>"oatmeal", "cookie_3"=>"chocolate"}, cookies.to_hash)
+ assert_equal({ "cookie_1"=>"", "cookie_2"=>"oatmeal", "cookie_3"=>"chocolate" }, cookies.to_hash)
end
end
@@ -513,14 +513,14 @@ class IntegrationProcessTest < ActionDispatch::IntegrationTest
assert_response :success
assert_equal "foo=bar; path=/", headers["Set-Cookie"]
- assert_equal({"foo"=>"bar"}, cookies.to_hash)
+ assert_equal({ "foo"=>"bar" }, cookies.to_hash)
get "/get_cookie"
assert_response :success
assert_equal "bar", body
assert_equal nil, headers["Set-Cookie"]
- assert_equal({"foo"=>"bar"}, cookies.to_hash)
+ assert_equal({ "foo"=>"bar" }, cookies.to_hash)
end
end
@@ -532,14 +532,14 @@ class IntegrationProcessTest < ActionDispatch::IntegrationTest
assert_response :success
assert_equal "foo=bar; path=/", headers["Set-Cookie"]
- assert_equal({"foo"=>"bar"}, cookies.to_hash)
+ assert_equal({ "foo"=>"bar" }, cookies.to_hash)
get "/get_cookie"
assert_response :success
assert_equal "bar", body
assert_equal nil, headers["Set-Cookie"]
- assert_equal({"foo"=>"bar"}, cookies.to_hash)
+ assert_equal({ "foo"=>"bar" }, cookies.to_hash)
end
end
@@ -778,9 +778,9 @@ class MetalIntegrationTest < ActionDispatch::IntegrationTest
class Poller
def self.call(env)
if env["PATH_INFO"] =~ /^\/success/
- [200, {"Content-Type" => "text/plain", "Content-Length" => "12"}, ["Hello World!"]]
+ [200, { "Content-Type" => "text/plain", "Content-Length" => "12" }, ["Hello World!"]]
else
- [404, {"Content-Type" => "text/plain", "Content-Length" => "0"}, []]
+ [404, { "Content-Type" => "text/plain", "Content-Length" => "0" }, []]
end
end
end
@@ -809,7 +809,7 @@ class MetalIntegrationTest < ActionDispatch::IntegrationTest
end
def test_pass_headers
- get "/success", headers: {"Referer" => "http://www.example.com/foo", "Host" => "http://nohost.com"}
+ get "/success", headers: { "Referer" => "http://www.example.com/foo", "Host" => "http://nohost.com" }
assert_equal "http://nohost.com", @request.env["HTTP_HOST"]
assert_equal "http://www.example.com/foo", @request.env["HTTP_REFERER"]
@@ -885,7 +885,7 @@ class ApplicationIntegrationTest < ActionDispatch::IntegrationTest
get "bar", to: "application_integration_test/test#index", as: :bar
mount MountedApp => "/mounted", :as => "mounted"
- get "fooz" => proc { |env| [ 200, {"X-Cascade" => "pass"}, [ "omg" ] ] }, :anchor => false
+ get "fooz" => proc { |env| [ 200, { "X-Cascade" => "pass" }, [ "omg" ] ] }, :anchor => false
get "fooz", to: "application_integration_test/test#index"
end
@@ -1158,7 +1158,7 @@ class IntegrationRequestsWithSessionSetup < ActionDispatch::IntegrationTest
def test_cookies_set_in_setup_are_persisted_through_the_session
get "/foo"
- assert_equal({"user_name"=>"david"}, cookies.to_hash)
+ assert_equal({ "user_name"=>"david" }, cookies.to_hash)
end
end
diff --git a/actionpack/test/controller/live_stream_test.rb b/actionpack/test/controller/live_stream_test.rb
index 9ec37e7559..1361e95081 100644
--- a/actionpack/test/controller/live_stream_test.rb
+++ b/actionpack/test/controller/live_stream_test.rb
@@ -161,7 +161,7 @@ module ActionController
response.stream.close
latch.count_down
- ActiveSupport::Dependencies.autoload_paths.reject! {|p| p == path}
+ ActiveSupport::Dependencies.autoload_paths.reject! { |p| p == path }
end
def thread_locals
@@ -285,7 +285,7 @@ module ActionController
def test_set_cookie
get :set_cookie
- assert_equal({"hello" => "world"}, @response.cookies)
+ assert_equal({ "hello" => "world" }, @response.cookies)
assert_equal "hello world", @response.body
end
diff --git a/actionpack/test/controller/log_subscriber_test.rb b/actionpack/test/controller/log_subscriber_test.rb
index 231283acdf..45a120acb6 100644
--- a/actionpack/test/controller/log_subscriber_test.rb
+++ b/actionpack/test/controller/log_subscriber_test.rb
@@ -138,7 +138,7 @@ class ACLogSubscriberTest < ActionController::TestCase
def test_process_action_without_parameters
get :show
wait
- assert_nil logs.detect {|l| l =~ /Parameters/ }
+ assert_nil logs.detect { |l| l =~ /Parameters/ }
end
def test_process_action_with_parameters
diff --git a/actionpack/test/controller/mime/respond_to_test.rb b/actionpack/test/controller/mime/respond_to_test.rb
index 2b6d319999..c5f8165d04 100644
--- a/actionpack/test/controller/mime/respond_to_test.rb
+++ b/actionpack/test/controller/mime/respond_to_test.rb
@@ -76,7 +76,7 @@ class RespondToController < ActionController::Base
def missing_templates
respond_to do |type|
# This test requires a block that is empty
- type.json { }
+ type.json {}
type.xml
end
end
@@ -221,7 +221,7 @@ class RespondToController < ActionController::Base
def variant_any
respond_to do |format|
format.html do |variant|
- variant.any(:tablet, :phablet){ render body: "any" }
+ variant.any(:tablet, :phablet) { render body: "any" }
variant.phone { render body: "phone" }
end
end
@@ -238,7 +238,7 @@ class RespondToController < ActionController::Base
def variant_inline_any
respond_to do |format|
- format.html.any(:tablet, :phablet){ render body: "any" }
+ format.html.any(:tablet, :phablet) { render body: "any" }
format.html.phone { render body: "phone" }
end
end
@@ -259,7 +259,7 @@ class RespondToController < ActionController::Base
def variant_any_with_none
respond_to do |format|
- format.html.any(:none, :phone){ render body: "none or phone" }
+ format.html.any(:none, :phone) { render body: "none or phone" }
end
end
@@ -267,8 +267,8 @@ class RespondToController < ActionController::Base
respond_to do |format|
format.html { render body: "HTML" }
format.any(:js, :xml) do |variant|
- variant.phone{ render body: "phone" }
- variant.any(:tablet, :phablet){ render body: "tablet" }
+ variant.phone { render body: "phone" }
+ variant.any(:tablet, :phablet) { render body: "tablet" }
end
end
end
@@ -674,7 +674,7 @@ class RespondToControllerTest < ActionController::TestCase
get :variant_without_implicit_template_rendering, xhr: true, params: { v: :does_not_matter }
assert_response :no_content
- assert_equal 1, logger.logged(:info).select{ |s| s == NO_CONTENT_WARNING }.size, "Implicit head :no_content not logged"
+ assert_equal 1, logger.logged(:info).select { |s| s == NO_CONTENT_WARNING }.size, "Implicit head :no_content not logged"
ensure
ActionController::Base.logger = old_logger
end
@@ -686,7 +686,7 @@ class RespondToControllerTest < ActionController::TestCase
get :variant_without_implicit_template_rendering, format: "json", params: { v: :does_not_matter }
assert_response :no_content
- assert_equal 1, logger.logged(:info).select{ |s| s == NO_CONTENT_WARNING }.size, "Implicit head :no_content not logged"
+ assert_equal 1, logger.logged(:info).select { |s| s == NO_CONTENT_WARNING }.size, "Implicit head :no_content not logged"
ensure
ActionController::Base.logger = old_logger
end
diff --git a/actionpack/test/controller/new_base/render_file_test.rb b/actionpack/test/controller/new_base/render_file_test.rb
index 9618157657..6d651e0104 100644
--- a/actionpack/test/controller/new_base/render_file_test.rb
+++ b/actionpack/test/controller/new_base/render_file_test.rb
@@ -30,7 +30,7 @@ module RenderFile
def with_locals
path = File.join(File.dirname(__FILE__), "../../fixtures/test/render_file_with_locals")
- render file: path, locals: {secret: "in the sauce"}
+ render file: path, locals: { secret: "in the sauce" }
end
end
diff --git a/actionpack/test/controller/parameter_encoding_test.rb b/actionpack/test/controller/parameter_encoding_test.rb
index 69a72c000b..7840b4f5c4 100644
--- a/actionpack/test/controller/parameter_encoding_test.rb
+++ b/actionpack/test/controller/parameter_encoding_test.rb
@@ -30,35 +30,35 @@ class ParameterEncodingTest < ActionController::TestCase
tests ParameterEncodingController
test "properly transcodes UTF8 parameters into declared encodings" do
- post :test_foo, params: {"foo" => "foo", "bar" => "bar", "baz" => "baz"}
+ post :test_foo, params: { "foo" => "foo", "bar" => "bar", "baz" => "baz" }
assert_response :success
assert_equal "UTF-8", @response.body
end
test "properly transcodes ASCII_8BIT parameters into declared encodings" do
- post :test_bar, params: {"foo" => "foo", "bar" => "bar", "baz" => "baz"}
+ post :test_bar, params: { "foo" => "foo", "bar" => "bar", "baz" => "baz" }
assert_response :success
assert_equal "ASCII-8BIT", @response.body
end
test "properly transcodes ISO_8859_1 parameters into declared encodings" do
- post :test_baz, params: {"foo" => "foo", "bar" => "bar", "baz" => "baz"}
+ post :test_baz, params: { "foo" => "foo", "bar" => "bar", "baz" => "baz" }
assert_response :success
assert_equal "ISO-8859-1", @response.body
end
test "does not transcode parameters when not specified" do
- post :test_no_change_to_baz, params: {"foo" => "foo", "bar" => "bar", "baz" => "baz"}
+ post :test_no_change_to_baz, params: { "foo" => "foo", "bar" => "bar", "baz" => "baz" }
assert_response :success
assert_equal "UTF-8", @response.body
end
test "respects different encoding declarations for a param per action" do
- post :test_baz_to_ascii, params: {"foo" => "foo", "bar" => "bar", "baz" => "baz"}
+ post :test_baz_to_ascii, params: { "foo" => "foo", "bar" => "bar", "baz" => "baz" }
assert_response :success
assert_equal "ASCII-8BIT", @response.body
diff --git a/actionpack/test/controller/parameters/accessors_test.rb b/actionpack/test/controller/parameters/accessors_test.rb
index a63512e8bd..8a522b2df8 100644
--- a/actionpack/test/controller/parameters/accessors_test.rb
+++ b/actionpack/test/controller/parameters/accessors_test.rb
@@ -13,7 +13,7 @@ class ParametersAccessorsTest < ActiveSupport::TestCase
first: "David",
last: "Heinemeier Hansson"
},
- addresses: [{city: "Chicago", state: "Illinois"}]
+ addresses: [{ city: "Chicago", state: "Illinois" }]
}
)
end
diff --git a/actionpack/test/controller/parameters/dup_test.rb b/actionpack/test/controller/parameters/dup_test.rb
index 152f608266..d88891ca30 100644
--- a/actionpack/test/controller/parameters/dup_test.rb
+++ b/actionpack/test/controller/parameters/dup_test.rb
@@ -12,7 +12,7 @@ class ParametersDupTest < ActiveSupport::TestCase
first: "David",
last: "Heinemeier Hansson"
},
- addresses: [{city: "Chicago", state: "Illinois"}]
+ addresses: [{ city: "Chicago", state: "Illinois" }]
}
)
end
diff --git a/actionpack/test/controller/parameters/mutators_test.rb b/actionpack/test/controller/parameters/mutators_test.rb
index a2dc84f2f7..e060e5180f 100644
--- a/actionpack/test/controller/parameters/mutators_test.rb
+++ b/actionpack/test/controller/parameters/mutators_test.rb
@@ -11,7 +11,7 @@ class ParametersMutatorsTest < ActiveSupport::TestCase
first: "David",
last: "Heinemeier Hansson"
},
- addresses: [{city: "Chicago", state: "Illinois"}]
+ addresses: [{ city: "Chicago", state: "Illinois" }]
}
)
end
diff --git a/actionpack/test/controller/parameters/nested_parameters_permit_test.rb b/actionpack/test/controller/parameters/nested_parameters_permit_test.rb
index f0155477c4..5f86901e30 100644
--- a/actionpack/test/controller/parameters/nested_parameters_permit_test.rb
+++ b/actionpack/test/controller/parameters/nested_parameters_permit_test.rb
@@ -73,7 +73,7 @@ class NestedParametersPermitTest < ActiveSupport::TestCase
genres: ["Tragedy"]
})
- permitted = params.permit book: {genres: []}
+ permitted = params.permit book: { genres: [] }
assert_equal ["Tragedy"], permitted[:book][:genres]
end
@@ -85,7 +85,7 @@ class NestedParametersPermitTest < ActiveSupport::TestCase
},
magazine: "Shakespeare Today")
- permitted = params.permit({book: ["title", :author]}, "magazine")
+ permitted = params.permit({ book: ["title", :author] }, "magazine")
assert_equal "Romeo and Juliet", permitted[:book][:title]
assert_equal "William Shakespeare", permitted[:book][:author]
assert_equal "Shakespeare Today", permitted[:magazine]
diff --git a/actionpack/test/controller/parameters/parameters_permit_test.rb b/actionpack/test/controller/parameters/parameters_permit_test.rb
index b42288636e..164efd936c 100644
--- a/actionpack/test/controller/parameters/parameters_permit_test.rb
+++ b/actionpack/test/controller/parameters/parameters_permit_test.rb
@@ -15,7 +15,7 @@ class ParametersPermitTest < ActiveSupport::TestCase
first: "David",
last: "Heinemeier Hansson"
},
- addresses: [{city: "Chicago", state: "Illinois"}]
+ addresses: [{ city: "Chicago", state: "Illinois" }]
}
)
@@ -39,13 +39,13 @@ class ParametersPermitTest < ActiveSupport::TestCase
end
test "iteration should not impact permit" do
- hash = {"foo"=>{"bar"=>{"0"=>{"baz"=>"hello", "zot"=>"1"}}}}
+ hash = { "foo"=>{ "bar"=>{ "0"=>{ "baz"=>"hello", "zot"=>"1" } } } }
params = ActionController::Parameters.new(hash)
walk_permitted params
sanitized = params[:foo].permit(bar: [:baz])
- assert_equal({"0"=>{"baz"=>"hello"}}, sanitized[:bar].to_unsafe_h)
+ assert_equal({ "0"=>{ "baz"=>"hello" } }, sanitized[:bar].to_unsafe_h)
end
test "if nothing is permitted, the hash becomes empty" do
@@ -98,7 +98,7 @@ class ParametersPermitTest < ActiveSupport::TestCase
end
test "key: hashes are filtered out" do
- [{}, {foo: 1}, {foo: "bar"}].each do |hash|
+ [{}, { foo: 1 }, { foo: "bar" }].each do |hash|
params = ActionController::Parameters.new(id: hash)
permitted = params.permit(:id)
assert_filtered_out permitted, :id
@@ -161,7 +161,7 @@ class ParametersPermitTest < ActiveSupport::TestCase
end
test "key to empty array: arrays of non-permitted scalar do not pass" do
- [[Object.new], [[]], [[1]], [{}], [{id: "1"}]].each do |non_permitted_scalar|
+ [[Object.new], [[]], [[1]], [{}], [{ id: "1" }]].each do |non_permitted_scalar|
params = ActionController::Parameters.new(id: non_permitted_scalar)
permitted = params.permit(id: [])
assert_filtered_out permitted, :id
@@ -203,10 +203,10 @@ class ParametersPermitTest < ActiveSupport::TestCase
# the cache does not get fooled, the hash is still wrapped as strong params,
# and not permitted.
test "mutated arrays are detected" do
- params = ActionController::Parameters.new(users: [{id: 1}])
+ params = ActionController::Parameters.new(users: [{ id: 1 }])
permitted = params.permit(users: [:id])
- permitted[:users] << {injected: 1}
+ permitted[:users] << { injected: 1 }
assert_not permitted[:users].last.permitted?
end
@@ -315,8 +315,8 @@ class ParametersPermitTest < ActiveSupport::TestCase
end
test "to_unsafe_h returns unfiltered params even after accessing few keys" do
- params = ActionController::Parameters.new("f"=>{"language_facet"=>["Tibetan"]})
- expected = {"f"=>{"language_facet"=>["Tibetan"]}}
+ params = ActionController::Parameters.new("f"=>{ "language_facet"=>["Tibetan"] })
+ expected = { "f"=>{ "language_facet"=>["Tibetan"] } }
assert params["f"].is_a? ActionController::Parameters
assert_equal expected, params.to_unsafe_h
diff --git a/actionpack/test/controller/params_wrapper_test.rb b/actionpack/test/controller/params_wrapper_test.rb
index 7800ff26d0..1549405fe7 100644
--- a/actionpack/test/controller/params_wrapper_test.rb
+++ b/actionpack/test/controller/params_wrapper_test.rb
@@ -150,7 +150,7 @@ class ParamsWrapperTest < ActionController::TestCase
def test_no_double_wrap_if_key_exists
with_default_wrapper_options do
@request.env["CONTENT_TYPE"] = "application/json"
- post :parse, params: { "user" => { "username" => "sikachu" }}
+ post :parse, params: { "user" => { "username" => "sikachu" } }
assert_parameters("user" => { "username" => "sikachu" })
end
end
@@ -158,8 +158,8 @@ class ParamsWrapperTest < ActionController::TestCase
def test_nested_params
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" }})
+ post :parse, params: { "person" => { "username" => "sikachu" } }
+ assert_parameters("person" => { "username" => "sikachu" }, "user" => { "person" => { "username" => "sikachu" } })
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
diff --git a/actionpack/test/controller/redirect_test.rb b/actionpack/test/controller/redirect_test.rb
index 0539580e14..495e41ce76 100644
--- a/actionpack/test/controller/redirect_test.rb
+++ b/actionpack/test/controller/redirect_test.rb
@@ -33,7 +33,7 @@ class RedirectController < ActionController::Base
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
@@ -118,7 +118,7 @@ class RedirectController < ActionController::Base
end
def redirect_to_with_block_and_options
- redirect_to proc { {action: "hello_world"} }
+ redirect_to proc { { action: "hello_world" } }
end
def redirect_with_header_break
diff --git a/actionpack/test/controller/render_json_test.rb b/actionpack/test/controller/render_json_test.rb
index 31b11588fd..213829bd9e 100644
--- a/actionpack/test/controller/render_json_test.rb
+++ b/actionpack/test/controller/render_json_test.rb
@@ -52,7 +52,7 @@ class RenderJsonTest < ActionController::TestCase
end
def render_json_with_render_to_string
- render json: {hello: render_to_string(partial: "partial")}
+ render json: { hello: render_to_string(partial: "partial") }
end
def render_json_with_extra_options
diff --git a/actionpack/test/controller/render_test.rb b/actionpack/test/controller/render_test.rb
index ba556c1bff..bf83131189 100644
--- a/actionpack/test/controller/render_test.rb
+++ b/actionpack/test/controller/render_test.rb
@@ -805,7 +805,7 @@ class HttpCacheForeverTest < ActionController::TestCase
tests HttpCacheForeverController
def test_cache_with_public
- get :cache_me_forever, params: {public: true}
+ get :cache_me_forever, params: { public: true }
assert_response :ok
assert_equal "max-age=#{100.years}, public", @response.headers["Cache-Control"]
assert_not_nil @response.etag
diff --git a/actionpack/test/controller/request_forgery_protection_test.rb b/actionpack/test/controller/request_forgery_protection_test.rb
index 03f112c34d..90d5ab3c67 100644
--- a/actionpack/test/controller/request_forgery_protection_test.rb
+++ b/actionpack/test/controller/request_forgery_protection_test.rb
@@ -398,7 +398,7 @@ module RequestForgeryProtectionTests
end
assert_cross_origin_not_blocked { get :same_origin_js, xhr: true }
- assert_cross_origin_not_blocked { get :same_origin_js, xhr: true, format: "js"}
+ assert_cross_origin_not_blocked { get :same_origin_js, xhr: true, format: "js" }
assert_cross_origin_not_blocked do
@request.accept = "text/javascript"
get :negotiate_same_origin, xhr: true
@@ -443,7 +443,7 @@ module RequestForgeryProtectionTests
assert_cross_origin_not_blocked { post :same_origin_js, params: { format: "js", custom_authenticity_token: @token } }
assert_cross_origin_not_blocked do
@request.accept = "text/javascript"
- post :negotiate_same_origin, params: { custom_authenticity_token: @token}
+ post :negotiate_same_origin, params: { custom_authenticity_token: @token }
end
end
@@ -613,7 +613,7 @@ class FreeCookieControllerTest < ActionController::TestCase
def test_should_allow_all_methods_without_token
SecureRandom.stub :base64, @token do
[:post, :patch, :put, :delete].each do |method|
- assert_nothing_raised { send(method, :index)}
+ assert_nothing_raised { send(method, :index) }
end
end
end
@@ -692,7 +692,7 @@ class PerFormTokensControllerTest < ActionController::TestCase
# This is required because PATH_INFO isn't reset between requests.
@request.env["PATH_INFO"] = "/per_form_tokens/post_one"
assert_nothing_raised do
- post :post_one, params: {custom_authenticity_token: form_token}
+ post :post_one, params: { custom_authenticity_token: form_token }
end
assert_response :success
end
@@ -707,7 +707,7 @@ class PerFormTokensControllerTest < ActionController::TestCase
# This is required because PATH_INFO isn't reset between requests.
@request.env["PATH_INFO"] = "/per_form_tokens/post_two"
assert_raises(ActionController::InvalidAuthenticityToken) do
- post :post_two, params: {custom_authenticity_token: form_token}
+ post :post_two, params: { custom_authenticity_token: form_token }
end
end
@@ -721,7 +721,7 @@ class PerFormTokensControllerTest < ActionController::TestCase
# This is required because PATH_INFO isn't reset between requests.
@request.env["PATH_INFO"] = "/per_form_tokens/post_one"
assert_raises(ActionController::InvalidAuthenticityToken) do
- patch :post_one, params: {custom_authenticity_token: form_token}
+ patch :post_one, params: { custom_authenticity_token: form_token }
end
end
@@ -777,13 +777,13 @@ class PerFormTokensControllerTest < ActionController::TestCase
# This is required because PATH_INFO isn't reset between requests.
@request.env["PATH_INFO"] = "/per_form_tokens/post_one"
assert_nothing_raised do
- post :post_one, params: {custom_authenticity_token: token}
+ post :post_one, params: { custom_authenticity_token: token }
end
assert_response :success
end
def test_ignores_params
- get :index, params: {form_path: "/per_form_tokens/post_one?foo=bar"}
+ get :index, params: { form_path: "/per_form_tokens/post_one?foo=bar" }
form_token = assert_presence_and_fetch_form_csrf_token
@@ -792,33 +792,33 @@ class PerFormTokensControllerTest < ActionController::TestCase
# This is required because PATH_INFO isn't reset between requests.
@request.env["PATH_INFO"] = "/per_form_tokens/post_one?foo=baz"
assert_nothing_raised do
- post :post_one, params: {custom_authenticity_token: form_token, baz: "foo"}
+ post :post_one, params: { custom_authenticity_token: form_token, baz: "foo" }
end
assert_response :success
end
def test_ignores_trailing_slash_during_generation
- get :index, params: {form_path: "/per_form_tokens/post_one/"}
+ get :index, params: { form_path: "/per_form_tokens/post_one/" }
form_token = assert_presence_and_fetch_form_csrf_token
# This is required because PATH_INFO isn't reset between requests.
@request.env["PATH_INFO"] = "/per_form_tokens/post_one"
assert_nothing_raised do
- post :post_one, params: {custom_authenticity_token: form_token}
+ post :post_one, params: { custom_authenticity_token: form_token }
end
assert_response :success
end
def test_ignores_origin_during_generation
- get :index, params: {form_path: "https://example.com/per_form_tokens/post_one/"}
+ get :index, params: { form_path: "https://example.com/per_form_tokens/post_one/" }
form_token = assert_presence_and_fetch_form_csrf_token
# This is required because PATH_INFO isn't reset between requests.
@request.env["PATH_INFO"] = "/per_form_tokens/post_one"
assert_nothing_raised do
- post :post_one, params: {custom_authenticity_token: form_token}
+ post :post_one, params: { custom_authenticity_token: form_token }
end
assert_response :success
end
@@ -831,19 +831,19 @@ class PerFormTokensControllerTest < ActionController::TestCase
# This is required because PATH_INFO isn't reset between requests.
@request.env["PATH_INFO"] = "/per_form_tokens/post_one/"
assert_nothing_raised do
- post :post_one, params: {custom_authenticity_token: form_token}
+ post :post_one, params: { custom_authenticity_token: form_token }
end
assert_response :success
end
def test_method_is_case_insensitive
- get :index, params: {form_method: "POST"}
+ get :index, params: { form_method: "POST" }
form_token = assert_presence_and_fetch_form_csrf_token
# This is required because PATH_INFO isn't reset between requests.
@request.env["PATH_INFO"] = "/per_form_tokens/post_one/"
assert_nothing_raised do
- post :post_one, params: {custom_authenticity_token: form_token}
+ post :post_one, params: { custom_authenticity_token: form_token }
end
assert_response :success
end
diff --git a/actionpack/test/controller/required_params_test.rb b/actionpack/test/controller/required_params_test.rb
index c9b0ac874d..315d1ff3e8 100644
--- a/actionpack/test/controller/required_params_test.rb
+++ b/actionpack/test/controller/required_params_test.rb
@@ -49,7 +49,7 @@ class ParametersRequireTest < ActiveSupport::TestCase
end
test "require array when all required params are present" do
- safe_params = ActionController::Parameters.new(person: {first_name: "Gaurish", title: "Mjallo", city: "Barcelona"})
+ safe_params = ActionController::Parameters.new(person: { first_name: "Gaurish", title: "Mjallo", city: "Barcelona" })
.require(:person)
.require([:first_name, :title])
@@ -59,7 +59,7 @@ class ParametersRequireTest < ActiveSupport::TestCase
test "require array when a required param is missing" do
assert_raises(ActionController::ParameterMissing) do
- ActionController::Parameters.new(person: {first_name: "Gaurish", title: nil})
+ ActionController::Parameters.new(person: { first_name: "Gaurish", title: nil })
.require(:person)
.require([:first_name, :title])
end
diff --git a/actionpack/test/controller/resources_test.rb b/actionpack/test/controller/resources_test.rb
index 91d3072fdb..29471939d0 100644
--- a/actionpack/test/controller/resources_test.rb
+++ b/actionpack/test/controller/resources_test.rb
@@ -28,7 +28,7 @@ class ResourcesTest < ActionController::TestCase
def test_override_paths_for_member_and_collection_methods
collection_methods = { rss: :get, reorder: :post, csv: :post }
member_methods = { rss: :get, atom: :get, upload: :post, fix: :post }
- path_names = {new: "nuevo", rss: "canal", fix: "corrigir" }
+ path_names = { new: "nuevo", rss: "canal", fix: "corrigir" }
with_restful_routing :messages,
collection: collection_methods,
@@ -77,7 +77,7 @@ class ResourcesTest < ActionController::TestCase
end
def test_multiple_resources_with_options
- expected_options = {controller: "threads", action: "index"}
+ expected_options = { controller: "threads", action: "index" }
with_restful_routing :messages, :comments, expected_options.slice(:controller) do
assert_recognizes(expected_options, path: "comments")
@@ -92,7 +92,7 @@ class ResourcesTest < ActionController::TestCase
end
def test_irregular_id_with_no_constraints_should_raise_error
- expected_options = {controller: "messages", action: "show", id: "1.1.1"}
+ expected_options = { controller: "messages", action: "show", id: "1.1.1" }
with_restful_routing :messages do
assert_raise(Assertion) do
@@ -102,24 +102,24 @@ class ResourcesTest < ActionController::TestCase
end
def test_irregular_id_with_constraints_should_pass
- expected_options = {controller: "messages", action: "show", id: "1.1.1"}
+ expected_options = { controller: "messages", action: "show", id: "1.1.1" }
- with_restful_routing(:messages, constraints: {id: /[0-9]\.[0-9]\.[0-9]/}) do
+ with_restful_routing(:messages, constraints: { id: /[0-9]\.[0-9]\.[0-9]/ }) do
assert_recognizes(expected_options, path: "messages/1.1.1", method: :get)
end
end
def test_with_path_prefix_constraints
- expected_options = {controller: "messages", action: "show", thread_id: "1.1.1", id: "1"}
- with_restful_routing :messages, path_prefix: "/thread/:thread_id", constraints: {thread_id: /[0-9]\.[0-9]\.[0-9]/} do
+ expected_options = { controller: "messages", action: "show", thread_id: "1.1.1", id: "1" }
+ with_restful_routing :messages, path_prefix: "/thread/:thread_id", constraints: { thread_id: /[0-9]\.[0-9]\.[0-9]/ } do
assert_recognizes(expected_options, path: "thread/1.1.1/messages/1", method: :get)
end
end
def test_irregular_id_constraints_should_get_passed_to_member_actions
- expected_options = {controller: "messages", action: "custom", id: "1.1.1"}
+ expected_options = { controller: "messages", action: "custom", id: "1.1.1" }
- with_restful_routing(:messages, member: {custom: :get}, constraints: {id: /[0-9]\.[0-9]\.[0-9]/}) do
+ with_restful_routing(:messages, member: { custom: :get }, constraints: { id: /[0-9]\.[0-9]\.[0-9]/ }) do
assert_recognizes(expected_options, path: "messages/1.1.1/custom", method: :get)
end
end
@@ -261,7 +261,7 @@ class ResourcesTest < ActionController::TestCase
def test_with_member_action
[:patch, :put, :post].each do |method|
with_restful_routing :messages, member: { mark: method } do
- mark_options = {action: "mark", id: "1"}
+ mark_options = { action: "mark", id: "1" }
mark_path = "/messages/1/mark"
assert_restful_routes_for :messages do |options|
assert_recognizes(options.merge(mark_options), path: mark_path, method: method)
@@ -275,24 +275,24 @@ class ResourcesTest < ActionController::TestCase
end
def test_with_member_action_and_requirement
- expected_options = {controller: "messages", action: "mark", id: "1.1.1"}
+ expected_options = { controller: "messages", action: "mark", id: "1.1.1" }
- with_restful_routing(:messages, constraints: {id: /[0-9]\.[0-9]\.[0-9]/}, member: { mark: :get }) do
+ with_restful_routing(:messages, constraints: { id: /[0-9]\.[0-9]\.[0-9]/ }, member: { mark: :get }) do
assert_recognizes(expected_options, path: "messages/1.1.1/mark", method: :get)
end
end
def test_member_when_override_paths_for_default_restful_actions_with
[:patch, :put, :post].each do |method|
- with_restful_routing :messages, member: { mark: method }, path_names: {new: "nuevo"} do
- mark_options = {action: "mark", id: "1", controller: "messages"}
+ with_restful_routing :messages, member: { mark: method }, path_names: { new: "nuevo" } do
+ mark_options = { action: "mark", id: "1", controller: "messages" }
mark_path = "/messages/1/mark"
- assert_restful_routes_for :messages, path_names: {new: "nuevo"} do |options|
+ assert_restful_routes_for :messages, path_names: { new: "nuevo" } do |options|
assert_recognizes(options.merge(mark_options), path: mark_path, method: method)
end
- assert_restful_named_routes_for :messages, path_names: {new: "nuevo"} do
+ assert_restful_named_routes_for :messages, path_names: { new: "nuevo" } do
assert_named_route mark_path, :mark_message_path, mark_options
end
end
@@ -312,7 +312,7 @@ class ResourcesTest < ActionController::TestCase
end
%w(mark unmark).each do |action|
- action_options = {action: action, id: "1"}
+ action_options = { action: action, id: "1" }
action_path = "/messages/1/#{action}"
assert_restful_routes_for :messages do |options|
assert_recognizes(options.merge(action_options), path: action_path, method: method)
@@ -359,7 +359,7 @@ class ResourcesTest < ActionController::TestCase
end
end
- preview_options = {action: "preview"}
+ preview_options = { action: "preview" }
preview_path = "/messages/new/preview"
assert_restful_routes_for :messages do |options|
assert_recognizes(options.merge(preview_options), path: preview_path, method: :post)
@@ -381,7 +381,7 @@ class ResourcesTest < ActionController::TestCase
end
end
- preview_options = {action: "preview", thread_id: "1"}
+ preview_options = { action: "preview", thread_id: "1" }
preview_path = "/threads/1/messages/new/preview"
assert_restful_routes_for :messages, path_prefix: "threads/1/", name_prefix: "thread_", options: { thread_id: "1" } do |options|
assert_recognizes(options.merge(preview_options), path: preview_path, method: :post)
@@ -403,7 +403,7 @@ class ResourcesTest < ActionController::TestCase
end
end
- preview_options = {action: "preview", thread_id: "1", format: "xml"}
+ preview_options = { action: "preview", thread_id: "1", format: "xml" }
preview_path = "/threads/1/messages/new/preview.xml"
assert_restful_routes_for :messages, path_prefix: "threads/1/", name_prefix: "thread_", options: { thread_id: "1" } do |options|
assert_recognizes(options.merge(preview_options), path: preview_path, method: :post)
@@ -561,7 +561,7 @@ class ResourcesTest < ActionController::TestCase
end
end
- reset_options = {action: "reset"}
+ reset_options = { action: "reset" }
reset_path = "/account/reset"
assert_singleton_routes_for :account do |options|
assert_recognizes(options.merge(reset_options), path: reset_path, method: method)
@@ -585,7 +585,7 @@ class ResourcesTest < ActionController::TestCase
end
%w(reset disable).each do |action|
- action_options = {action: action}
+ action_options = { action: action }
action_path = "/account/#{action}"
assert_singleton_routes_for :account do |options|
assert_recognizes(options.merge(action_options), path: action_path, method: method)
@@ -743,7 +743,7 @@ class ResourcesTest < ActionController::TestCase
end
end
- assert_simply_restful_for :images, controller: "backoffice/images", name_prefix: "backoffice_product_", path_prefix: "backoffice/products/1/", options: {product_id: "1"}
+ assert_simply_restful_for :images, controller: "backoffice/images", name_prefix: "backoffice_product_", path_prefix: "backoffice/products/1/", options: { product_id: "1" }
end
end
@@ -759,15 +759,15 @@ class ResourcesTest < ActionController::TestCase
end
end
- assert_simply_restful_for :images, controller: "backoffice/admin/images", name_prefix: "backoffice_admin_product_", path_prefix: "backoffice/admin/products/1/", options: {product_id: "1"}
+ assert_simply_restful_for :images, controller: "backoffice/admin/images", name_prefix: "backoffice_admin_product_", path_prefix: "backoffice/admin/products/1/", options: { product_id: "1" }
end
end
def test_with_path_segment
with_restful_routing :messages do
assert_simply_restful_for :messages
- assert_recognizes({controller: "messages", action: "index"}, "/messages")
- assert_recognizes({controller: "messages", action: "index"}, "/messages/")
+ assert_recognizes({ controller: "messages", action: "index" }, "/messages")
+ assert_recognizes({ controller: "messages", action: "index" }, "/messages/")
end
with_routing do |set|
@@ -775,8 +775,8 @@ class ResourcesTest < ActionController::TestCase
resources :messages, path: "reviews"
end
assert_simply_restful_for :messages, as: "reviews"
- assert_recognizes({controller: "messages", action: "index"}, "/reviews")
- assert_recognizes({controller: "messages", action: "index"}, "/reviews/")
+ assert_recognizes({ controller: "messages", action: "index" }, "/reviews")
+ assert_recognizes({ controller: "messages", action: "index" }, "/reviews/")
end
end
@@ -791,13 +791,13 @@ class ResourcesTest < ActionController::TestCase
end
end
- assert_simply_restful_for :product_reviews, controller: "messages", as: "reviews", name_prefix: "product_", path_prefix: "products/1/", options: {product_id: "1"}
- assert_simply_restful_for :tutor_reviews,controller: "comments", as: "reviews", name_prefix: "tutor_", path_prefix: "tutors/1/", options: {tutor_id: "1"}
+ assert_simply_restful_for :product_reviews, controller: "messages", as: "reviews", name_prefix: "product_", path_prefix: "products/1/", options: { product_id: "1" }
+ assert_simply_restful_for :tutor_reviews,controller: "comments", as: "reviews", name_prefix: "tutor_", path_prefix: "tutors/1/", options: { tutor_id: "1" }
end
end
def test_with_path_segment_path_prefix_constraints
- expected_options = {controller: "messages", action: "show", thread_id: "1.1.1", id: "1"}
+ expected_options = { controller: "messages", action: "show", thread_id: "1.1.1", id: "1" }
with_routing do |set|
set.draw do
scope "/thread/:thread_id", constraints: { thread_id: /[0-9]\.[0-9]\.[0-9]/ } do
@@ -1125,7 +1125,7 @@ class ResourcesTest < ActionController::TestCase
def with_singleton_resources(*args)
with_routing do |set|
- set.draw {resource(*args) }
+ set.draw { resource(*args) }
yield
end
end
diff --git a/actionpack/test/controller/routing_test.rb b/actionpack/test/controller/routing_test.rb
index 9f0e3bff15..d1cc0f7d68 100644
--- a/actionpack/test/controller/routing_test.rb
+++ b/actionpack/test/controller/routing_test.rb
@@ -91,7 +91,7 @@ class LegacyRouteSetTests < ActiveSupport::TestCase
end
hash = ActiveSupport::JSON.decode get(URI("http://example.org/journey/faithfully-omg"))
- assert_equal({"artist"=>"journey", "song"=>"faithfully"}, hash)
+ assert_equal({ "artist"=>"journey", "song"=>"faithfully" }, hash)
end
def test_id_with_dash
@@ -103,7 +103,7 @@ class LegacyRouteSetTests < ActiveSupport::TestCase
end
hash = ActiveSupport::JSON.decode get(URI("http://example.org/journey/faithfully-omg"))
- assert_equal({"id"=>"faithfully-omg"}, hash)
+ assert_equal({ "id"=>"faithfully-omg" }, hash)
end
def test_dash_with_custom_regexp
@@ -115,7 +115,7 @@ class LegacyRouteSetTests < ActiveSupport::TestCase
end
hash = ActiveSupport::JSON.decode get(URI("http://example.org/journey/123-omg"))
- assert_equal({"artist"=>"journey", "song"=>"123"}, hash)
+ assert_equal({ "artist"=>"journey", "song"=>"123" }, hash)
assert_equal "Not Found", get(URI("http://example.org/journey/faithfully-omg"))
end
@@ -128,7 +128,7 @@ class LegacyRouteSetTests < ActiveSupport::TestCase
end
hash = ActiveSupport::JSON.decode get(URI("http://example.org/journey/omg-faithfully"))
- assert_equal({"artist"=>"journey", "song"=>"faithfully"}, hash)
+ assert_equal({ "artist"=>"journey", "song"=>"faithfully" }, hash)
end
def test_pre_dash_with_custom_regexp
@@ -140,7 +140,7 @@ class LegacyRouteSetTests < ActiveSupport::TestCase
end
hash = ActiveSupport::JSON.decode get(URI("http://example.org/journey/omg-123"))
- assert_equal({"artist"=>"journey", "song"=>"123"}, hash)
+ assert_equal({ "artist"=>"journey", "song"=>"123" }, hash)
assert_equal "Not Found", get(URI("http://example.org/journey/omg-faithfully"))
end
@@ -286,7 +286,7 @@ class LegacyRouteSetTests < ActiveSupport::TestCase
}
end
assert_equal "foo", get(URI("http://example.org/posts/1/foo.js"))
- assert_equal({id: "1", filters: "foo", format: "js"}, params)
+ assert_equal({ id: "1", filters: "foo", format: "js" }, params)
end
def test_specific_controller_action_failure
@@ -301,11 +301,11 @@ class LegacyRouteSetTests < ActiveSupport::TestCase
def test_default_setup
rs.draw { ActiveSupport::Deprecation.silence { get "/:controller(/:action(/:id))" } }
- assert_equal({controller: "content", action: "index"}, rs.recognize_path("/content"))
- assert_equal({controller: "content", action: "list"}, rs.recognize_path("/content/list"))
- assert_equal({controller: "content", action: "show", id: "10"}, rs.recognize_path("/content/show/10"))
+ assert_equal({ controller: "content", action: "index" }, rs.recognize_path("/content"))
+ assert_equal({ controller: "content", action: "list" }, rs.recognize_path("/content/list"))
+ assert_equal({ controller: "content", action: "show", id: "10" }, rs.recognize_path("/content/show/10"))
- assert_equal({controller: "admin/user", action: "show", id: "10"}, rs.recognize_path("/admin/user/show/10"))
+ 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)
@@ -330,7 +330,7 @@ class LegacyRouteSetTests < ActiveSupport::TestCase
get ":url", controller: "content", action: "translate"
end
- assert_equal({controller: "content", action: "translate", url: "example"}, rs.recognize_path("/example"))
+ assert_equal({ controller: "content", action: "translate", url: "example" }, rs.recognize_path("/example"))
end
def test_route_with_regexp_for_action
@@ -351,9 +351,9 @@ class LegacyRouteSetTests < ActiveSupport::TestCase
end
end
- assert_equal({controller: "admin/user", admintoken: "foo", action: "index"},
+ assert_equal({ controller: "admin/user", admintoken: "foo", action: "index" },
rs.recognize_path("/admin/user/foo"))
- assert_equal({controller: "content", action: "foo"},
+ 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")
@@ -366,8 +366,8 @@ class LegacyRouteSetTests < ActiveSupport::TestCase
get "/:controller(/:action(/:id))", controller: /admin\/(accounts|users)/
end
end
- assert_equal({controller: "admin/accounts", action: "index"}, rs.recognize_path("/admin/accounts"))
- assert_equal({controller: "admin/users", action: "index"}, rs.recognize_path("/admin/users"))
+ assert_equal({ controller: "admin/accounts", action: "index" }, rs.recognize_path("/admin/accounts"))
+ assert_equal({ controller: "admin/users", action: "index" }, rs.recognize_path("/admin/users"))
assert_raise(ActionController::RoutingError) { rs.recognize_path("/admin/products") }
end
@@ -377,22 +377,22 @@ class LegacyRouteSetTests < ActiveSupport::TestCase
get ":controller/:action/:file",
controller: /admin|user/,
action: /upload|download/,
- defaults: {file: nil},
- constraints: {file: %r{[^/]+(\.[^/]+)?}}
+ defaults: { file: nil },
+ constraints: { file: %r{[^/]+(\.[^/]+)?} }
end
end
# Without a file extension
assert_equal "/user/download/file",
url_for(rs, controller: "user", action: "download", file: "file")
- assert_equal({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")
- assert_equal({controller: "user", action: "download", file: "file.jpg"},
+ assert_equal({ controller: "user", action: "download", file: "file.jpg" },
rs.recognize_path("/user/download/file.jpg"))
end
@@ -603,7 +603,7 @@ class LegacyRouteSetTests < ActiveSupport::TestCase
end
get URI("http://test.host/pages/boo")
- assert_equal({controller: "content", action: "show_file", path: "pages/boo"},
+ assert_equal({ controller: "content", action: "show_file", path: "pages/boo" },
controller.request.path_parameters)
assert_equal "/pages/boo",
@@ -638,9 +638,9 @@ class LegacyRouteSetTests < ActiveSupport::TestCase
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"))
- assert_equal({controller: "content", action: "show_page", id: "10"}, rs.recognize_path("/page/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"))
+ assert_equal({ controller: "content", action: "show_page", id: "10" }, rs.recognize_path("/page/10"))
end
# For newer revision
@@ -672,7 +672,7 @@ class LegacyRouteSetTests < ActiveSupport::TestCase
def test_requirement_should_prevent_optional_id
rs.draw do
- get "post/:id" => "post#show", :constraints => {id: /\d+/}, :as => "post"
+ get "post/:id" => "post#show", :constraints => { id: /\d+/ }, :as => "post"
end
assert_equal "/post/10", url_for(rs, controller: "post", action: "show", id: 10)
@@ -1111,8 +1111,8 @@ class RouteSetTest < ActiveSupport::TestCase
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/"))
+ 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/"))
end
def test_route_with_parameter_shell
@@ -1124,12 +1124,12 @@ class RouteSetTest < ActiveSupport::TestCase
end
end
- assert_equal({controller: "pages", action: "index"}, request_path_params("/pages"))
- assert_equal({controller: "pages", action: "index"}, request_path_params("/pages/index"))
- assert_equal({controller: "pages", action: "list"}, request_path_params("/pages/list"))
+ assert_equal({ controller: "pages", action: "index" }, request_path_params("/pages"))
+ assert_equal({ controller: "pages", action: "index" }, request_path_params("/pages/index"))
+ assert_equal({ controller: "pages", action: "list" }, request_path_params("/pages/list"))
- assert_equal({controller: "pages", action: "show", id: "10"}, request_path_params("/pages/show/10"))
- assert_equal({controller: "pages", action: "show", id: "10"}, request_path_params("/page/10"))
+ assert_equal({ controller: "pages", action: "show", id: "10" }, request_path_params("/pages/show/10"))
+ assert_equal({ controller: "pages", action: "show", id: "10" }, request_path_params("/page/10"))
end
def test_route_constraints_on_request_object_with_anchors_are_valid
@@ -1189,8 +1189,8 @@ class RouteSetTest < ActiveSupport::TestCase
get "page/:id" => "pages#show", :id => /[a-zA-Z0-9\+]+/
end
- assert_equal({controller: "pages", action: "show", id: "10"}, request_path_params("/page/10"))
- assert_equal({controller: "pages", action: "show", id: "hello+world"}, request_path_params("/page/hello+world"))
+ assert_equal({ controller: "pages", action: "show", id: "10" }, request_path_params("/page/10"))
+ assert_equal({ controller: "pages", action: "show", id: "hello+world" }, request_path_params("/page/hello+world"))
end
def test_recognize_with_http_methods
@@ -1500,7 +1500,7 @@ class RouteSetTest < ActiveSupport::TestCase
end
get URI("http://test.host/posts.xml")
- assert_equal({controller: "posts", action: "index", format: "xml"},
+ assert_equal({ controller: "posts", action: "index", format: "xml" },
controller.request.path_parameters)
assert_equal "/posts", controller.url_for(
@@ -1591,12 +1591,12 @@ class RouteSetTest < ActiveSupport::TestCase
def test_route_with_subdomain_and_constraints_must_receive_params
name_param = nil
set.draw do
- get "page/:name" => "pages#show", :constraints => lambda {|request|
+ get "page/:name" => "pages#show", :constraints => lambda { |request|
name_param = request.params[:name]
return true
}
end
- assert_equal({controller: "pages", action: "show", name: "mypage"},
+ assert_equal({ controller: "pages", action: "show", name: "mypage" },
set.recognize_path("http://subdomain.example.org/page/mypage"))
assert_equal(name_param, "mypage")
end
@@ -1604,19 +1604,19 @@ class RouteSetTest < ActiveSupport::TestCase
def test_route_requirement_recognize_with_ignore_case
set.draw do
get "page/:name" => "pages#show",
- :constraints => {name: /(david|jamis)/i}
+ :constraints => { name: /(david|jamis)/i }
end
- assert_equal({controller: "pages", action: "show", name: "jamis"}, set.recognize_path("/page/jamis"))
+ assert_equal({ controller: "pages", action: "show", name: "jamis" }, set.recognize_path("/page/jamis"))
assert_raise ActionController::RoutingError do
set.recognize_path("/page/davidjamis")
end
- assert_equal({controller: "pages", action: "show", name: "DAVID"}, set.recognize_path("/page/DAVID"))
+ assert_equal({ controller: "pages", action: "show", name: "DAVID" }, set.recognize_path("/page/DAVID"))
end
def test_route_requirement_generate_with_ignore_case
set.draw do
get "page/:name" => "pages#show",
- :constraints => {name: /(david|jamis)/i}
+ :constraints => { name: /(david|jamis)/i }
end
url = url_for(set, controller: "pages", action: "show", name: "david")
@@ -1631,15 +1631,15 @@ class RouteSetTest < ActiveSupport::TestCase
def test_route_requirement_recognize_with_extended_syntax
set.draw do
get "page/:name" => "pages#show",
- :constraints => {name: / # Desperately overcommented regexp
+ :constraints => { name: / # Desperately overcommented regexp
( #Either
david #The Creator
| #Or
jamis #The Deployer
- )/x}
+ )/x }
end
- assert_equal({controller: "pages", action: "show", name: "jamis"}, set.recognize_path("/page/jamis"))
- assert_equal({controller: "pages", action: "show", name: "david"}, set.recognize_path("/page/david"))
+ assert_equal({ controller: "pages", action: "show", name: "jamis" }, set.recognize_path("/page/jamis"))
+ assert_equal({ controller: "pages", action: "show", name: "david" }, set.recognize_path("/page/david"))
assert_raise ActionController::RoutingError do
set.recognize_path("/page/david #The Creator")
end
@@ -1651,15 +1651,15 @@ class RouteSetTest < ActiveSupport::TestCase
def test_route_requirement_with_xi_modifiers
set.draw do
get "page/:name" => "pages#show",
- :constraints => {name: / # Desperately overcommented regexp
+ :constraints => { name: / # Desperately overcommented regexp
( #Either
david #The Creator
| #Or
jamis #The Deployer
- )/xi}
+ )/xi }
end
- assert_equal({controller: "pages", action: "show", name: "JAMIS"},
+ assert_equal({ controller: "pages", action: "show", name: "JAMIS" },
set.recognize_path("/page/JAMIS"))
assert_equal "/page/JAMIS",
@@ -1671,8 +1671,8 @@ class RouteSetTest < ActiveSupport::TestCase
get "unnamed", controller: :pages, action: :show, name: :as_symbol
get "named" , controller: :pages, action: :show, name: :as_symbol, as: :named
end
- assert_equal({controller: "pages", action: "show", name: :as_symbol}, set.recognize_path("/unnamed"))
- assert_equal({controller: "pages", action: "show", name: :as_symbol}, set.recognize_path("/named"))
+ assert_equal({ controller: "pages", action: "show", name: :as_symbol }, set.recognize_path("/unnamed"))
+ assert_equal({ controller: "pages", action: "show", name: :as_symbol }, set.recognize_path("/named"))
end
def test_regexp_chunk_should_add_question_mark_for_optionals
@@ -1684,8 +1684,8 @@ class RouteSetTest < ActiveSupport::TestCase
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"))
+ assert_equal({ controller: "foo", action: "index" }, set.recognize_path("/"))
+ assert_equal({ controller: "bar", action: "index" }, set.recognize_path("/hello"))
end
def test_assign_route_options_with_anchor_chars
@@ -1697,7 +1697,7 @@ class RouteSetTest < ActiveSupport::TestCase
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"))
+ assert_equal({ controller: "cars", action: "buy", person: "1", car: "2" }, set.recognize_path("/cars/buy/1/2"))
end
def test_segmentation_of_dot_path
@@ -1709,7 +1709,7 @@ class RouteSetTest < ActiveSupport::TestCase
assert_equal "/books/list.rss", url_for(set, controller: "books", action: "list")
- assert_equal({controller: "books", action: "list"}, set.recognize_path("/books/list.rss"))
+ assert_equal({ controller: "books", action: "list" }, set.recognize_path("/books/list.rss"))
end
def test_segmentation_of_dynamic_dot_path
@@ -1724,10 +1724,10 @@ class RouteSetTest < ActiveSupport::TestCase
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"))
- assert_equal({controller: "books", action: "list"}, set.recognize_path("/books/list"))
- assert_equal({controller: "books", action: "index"}, set.recognize_path("/books"))
+ 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"))
+ assert_equal({ controller: "books", action: "list" }, set.recognize_path("/books/list"))
+ assert_equal({ controller: "books", action: "index" }, set.recognize_path("/books"))
end
def test_slashes_are_implied
@@ -1737,14 +1737,14 @@ class RouteSetTest < ActiveSupport::TestCase
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"))
- assert_equal({controller: "content", action: "list"}, set.recognize_path("/content/list"))
- assert_equal({controller: "content", action: "show", id: "1"}, set.recognize_path("/content/show/1"))
+ assert_equal({ controller: "content", action: "index" }, set.recognize_path("/content"))
+ assert_equal({ controller: "content", action: "index" }, set.recognize_path("/content/index"))
+ assert_equal({ controller: "content", action: "list" }, set.recognize_path("/content/list"))
+ assert_equal({ controller: "content", action: "show", id: "1" }, set.recognize_path("/content/show/1"))
end
def test_default_route_recognition
- expected = {controller: "pages", action: "show", id: "10"}
+ expected = { controller: "pages", action: "show", id: "10" }
assert_equal expected, default_route_set.recognize_path("/pages/show/10")
assert_equal expected, default_route_set.recognize_path("/pages/show/10/")
@@ -1860,19 +1860,19 @@ class RouteSetTest < ActiveSupport::TestCase
controller.request.path_parameters
}
- assert_equal({controller: "blog", action: "index"}, recognize_path.("/blog"))
- assert_equal({controller: "blog", action: "show", id: "123"}, recognize_path.("/blog/show/123"))
- assert_equal({controller: "blog", action: "show_date", year: "2004", day: nil, month: nil }, recognize_path.("/blog/2004"))
- assert_equal({controller: "blog", action: "show_date", year: "2004", month: "12", day: nil }, recognize_path.("/blog/2004/12"))
- assert_equal({controller: "blog", action: "show_date", year: "2004", month: "12", day: "25"}, recognize_path.("/blog/2004/12/25"))
- assert_equal({controller: "articles", action: "edit", id: "123"}, recognize_path.("/blog/articles/edit/123"))
- assert_equal({controller: "articles", action: "show_stats"}, recognize_path.("/blog/articles/show_stats"))
- assert_equal({controller: "blog", action: "unknown_request", anything: "blog/wibble"}, recognize_path.("/blog/wibble"))
- assert_equal({controller: "blog", action: "unknown_request", anything: "junk"}, recognize_path.("/junk"))
+ assert_equal({ controller: "blog", action: "index" }, recognize_path.("/blog"))
+ assert_equal({ controller: "blog", action: "show", id: "123" }, recognize_path.("/blog/show/123"))
+ assert_equal({ controller: "blog", action: "show_date", year: "2004", day: nil, month: nil }, recognize_path.("/blog/2004"))
+ assert_equal({ controller: "blog", action: "show_date", year: "2004", month: "12", day: nil }, recognize_path.("/blog/2004/12"))
+ assert_equal({ controller: "blog", action: "show_date", year: "2004", month: "12", day: "25" }, recognize_path.("/blog/2004/12/25"))
+ assert_equal({ controller: "articles", action: "edit", id: "123" }, recognize_path.("/blog/articles/edit/123"))
+ assert_equal({ controller: "articles", action: "show_stats" }, recognize_path.("/blog/articles/show_stats"))
+ assert_equal({ controller: "blog", action: "unknown_request", anything: "blog/wibble" }, recognize_path.("/blog/wibble"))
+ assert_equal({ controller: "blog", action: "unknown_request", anything: "junk" }, recognize_path.("/junk"))
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({ 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))
@@ -1966,76 +1966,76 @@ class RackMountIntegrationTests < ActiveSupport::TestCase
end
def test_recognize_path
- assert_equal({controller: "admin/users", action: "index"}, @routes.recognize_path("/admin/users", method: :get))
- assert_equal({controller: "admin/users", action: "create"}, @routes.recognize_path("/admin/users", method: :post))
- assert_equal({controller: "admin/users", action: "new"}, @routes.recognize_path("/admin/users/new", method: :get))
- assert_equal({controller: "admin/users", action: "show", id: "1"}, @routes.recognize_path("/admin/users/1", method: :get))
- assert_equal({controller: "admin/users", action: "update", id: "1"}, @routes.recognize_path("/admin/users/1", method: :put))
- assert_equal({controller: "admin/users", action: "destroy", id: "1"}, @routes.recognize_path("/admin/users/1", method: :delete))
- assert_equal({controller: "admin/users", action: "edit", id: "1"}, @routes.recognize_path("/admin/users/1/edit", method: :get))
-
- assert_equal({controller: "admin/posts", action: "index"}, @routes.recognize_path("/admin/posts", method: :get))
- assert_equal({controller: "admin/posts", action: "new"}, @routes.recognize_path("/admin/posts/new", method: :get))
-
- assert_equal({controller: "api/users", action: "index"}, @routes.recognize_path("/api", method: :get))
- assert_equal({controller: "api/users", action: "index"}, @routes.recognize_path("/api/", method: :get))
-
- assert_equal({controller: "posts", action: "show_date", year: "2009", month: nil, day: nil }, @routes.recognize_path("/blog/2009", method: :get))
- assert_equal({controller: "posts", action: "show_date", year: "2009", month: "01", day: nil }, @routes.recognize_path("/blog/2009/01", method: :get))
- assert_equal({controller: "posts", action: "show_date", year: "2009", month: "01", day: "01"}, @routes.recognize_path("/blog/2009/01/01", method: :get))
-
- assert_equal({controller: "archive", action: "index", year: "2010"}, @routes.recognize_path("/archive/2010"))
- assert_equal({controller: "archive", action: "index"}, @routes.recognize_path("/archive"))
-
- assert_equal({controller: "people", action: "index"}, @routes.recognize_path("/people", method: :get))
- assert_equal({controller: "people", action: "index", format: "xml"}, @routes.recognize_path("/people.xml", method: :get))
- assert_equal({controller: "people", action: "create"}, @routes.recognize_path("/people", method: :post))
- assert_equal({controller: "people", action: "new"}, @routes.recognize_path("/people/new", method: :get))
- assert_equal({controller: "people", action: "show", id: "1"}, @routes.recognize_path("/people/1", method: :get))
- assert_equal({controller: "people", action: "show", id: "1", format: "xml"}, @routes.recognize_path("/people/1.xml", method: :get))
- assert_equal({controller: "people", action: "update", id: "1"}, @routes.recognize_path("/people/1", method: :put))
- assert_equal({controller: "people", action: "destroy", id: "1"}, @routes.recognize_path("/people/1", method: :delete))
- assert_equal({controller: "people", action: "edit", id: "1"}, @routes.recognize_path("/people/1/edit", method: :get))
- assert_equal({controller: "people", action: "edit", id: "1", format: "xml"}, @routes.recognize_path("/people/1/edit.xml", method: :get))
-
- assert_equal({controller: "symbols", action: "show", name: :as_symbol}, @routes.recognize_path("/symbols"))
- assert_equal({controller: "foo", action: "id_default", id: "1"}, @routes.recognize_path("/id_default/1"))
- assert_equal({controller: "foo", action: "id_default", id: "2"}, @routes.recognize_path("/id_default/2"))
- assert_equal({controller: "foo", action: "id_default", id: 1 }, @routes.recognize_path("/id_default"))
- assert_equal({controller: "foo", action: "get_or_post"}, @routes.recognize_path("/get_or_post", method: :get))
- assert_equal({controller: "foo", action: "get_or_post"}, @routes.recognize_path("/get_or_post", method: :post))
+ assert_equal({ controller: "admin/users", action: "index" }, @routes.recognize_path("/admin/users", method: :get))
+ assert_equal({ controller: "admin/users", action: "create" }, @routes.recognize_path("/admin/users", method: :post))
+ assert_equal({ controller: "admin/users", action: "new" }, @routes.recognize_path("/admin/users/new", method: :get))
+ assert_equal({ controller: "admin/users", action: "show", id: "1" }, @routes.recognize_path("/admin/users/1", method: :get))
+ assert_equal({ controller: "admin/users", action: "update", id: "1" }, @routes.recognize_path("/admin/users/1", method: :put))
+ assert_equal({ controller: "admin/users", action: "destroy", id: "1" }, @routes.recognize_path("/admin/users/1", method: :delete))
+ assert_equal({ controller: "admin/users", action: "edit", id: "1" }, @routes.recognize_path("/admin/users/1/edit", method: :get))
+
+ assert_equal({ controller: "admin/posts", action: "index" }, @routes.recognize_path("/admin/posts", method: :get))
+ assert_equal({ controller: "admin/posts", action: "new" }, @routes.recognize_path("/admin/posts/new", method: :get))
+
+ assert_equal({ controller: "api/users", action: "index" }, @routes.recognize_path("/api", method: :get))
+ assert_equal({ controller: "api/users", action: "index" }, @routes.recognize_path("/api/", method: :get))
+
+ assert_equal({ controller: "posts", action: "show_date", year: "2009", month: nil, day: nil }, @routes.recognize_path("/blog/2009", method: :get))
+ assert_equal({ controller: "posts", action: "show_date", year: "2009", month: "01", day: nil }, @routes.recognize_path("/blog/2009/01", method: :get))
+ assert_equal({ controller: "posts", action: "show_date", year: "2009", month: "01", day: "01" }, @routes.recognize_path("/blog/2009/01/01", method: :get))
+
+ assert_equal({ controller: "archive", action: "index", year: "2010" }, @routes.recognize_path("/archive/2010"))
+ assert_equal({ controller: "archive", action: "index" }, @routes.recognize_path("/archive"))
+
+ assert_equal({ controller: "people", action: "index" }, @routes.recognize_path("/people", method: :get))
+ assert_equal({ controller: "people", action: "index", format: "xml" }, @routes.recognize_path("/people.xml", method: :get))
+ assert_equal({ controller: "people", action: "create" }, @routes.recognize_path("/people", method: :post))
+ assert_equal({ controller: "people", action: "new" }, @routes.recognize_path("/people/new", method: :get))
+ assert_equal({ controller: "people", action: "show", id: "1" }, @routes.recognize_path("/people/1", method: :get))
+ assert_equal({ controller: "people", action: "show", id: "1", format: "xml" }, @routes.recognize_path("/people/1.xml", method: :get))
+ assert_equal({ controller: "people", action: "update", id: "1" }, @routes.recognize_path("/people/1", method: :put))
+ assert_equal({ controller: "people", action: "destroy", id: "1" }, @routes.recognize_path("/people/1", method: :delete))
+ assert_equal({ controller: "people", action: "edit", id: "1" }, @routes.recognize_path("/people/1/edit", method: :get))
+ assert_equal({ controller: "people", action: "edit", id: "1", format: "xml" }, @routes.recognize_path("/people/1/edit.xml", method: :get))
+
+ assert_equal({ controller: "symbols", action: "show", name: :as_symbol }, @routes.recognize_path("/symbols"))
+ assert_equal({ controller: "foo", action: "id_default", id: "1" }, @routes.recognize_path("/id_default/1"))
+ assert_equal({ controller: "foo", action: "id_default", id: "2" }, @routes.recognize_path("/id_default/2"))
+ assert_equal({ controller: "foo", action: "id_default", id: 1 }, @routes.recognize_path("/id_default"))
+ assert_equal({ controller: "foo", action: "get_or_post" }, @routes.recognize_path("/get_or_post", method: :get))
+ assert_equal({ controller: "foo", action: "get_or_post" }, @routes.recognize_path("/get_or_post", method: :post))
assert_raise(ActionController::RoutingError) { @routes.recognize_path("/get_or_post", method: :put) }
assert_raise(ActionController::RoutingError) { @routes.recognize_path("/get_or_post", method: :delete) }
- assert_equal({controller: "posts", action: "index", optional: "bar"}, @routes.recognize_path("/optional/bar"))
+ assert_equal({ controller: "posts", action: "index", optional: "bar" }, @routes.recognize_path("/optional/bar"))
assert_raise(ActionController::RoutingError) { @routes.recognize_path("/optional") }
- assert_equal({controller: "posts", action: "show", id: "1", ws: true}, @routes.recognize_path("/ws/posts/show/1", method: :get))
- assert_equal({controller: "posts", action: "list", ws: true}, @routes.recognize_path("/ws/posts/list", method: :get))
- assert_equal({controller: "posts", action: "index", ws: true}, @routes.recognize_path("/ws/posts", method: :get))
+ assert_equal({ controller: "posts", action: "show", id: "1", ws: true }, @routes.recognize_path("/ws/posts/show/1", method: :get))
+ assert_equal({ controller: "posts", action: "list", ws: true }, @routes.recognize_path("/ws/posts/list", method: :get))
+ assert_equal({ controller: "posts", action: "index", ws: true }, @routes.recognize_path("/ws/posts", method: :get))
- assert_equal({controller: "account", action: "subscription"}, @routes.recognize_path("/account", method: :get))
- assert_equal({controller: "account", action: "subscription"}, @routes.recognize_path("/account/subscription", method: :get))
- assert_equal({controller: "account", action: "billing"}, @routes.recognize_path("/account/billing", method: :get))
+ assert_equal({ controller: "account", action: "subscription" }, @routes.recognize_path("/account", method: :get))
+ assert_equal({ controller: "account", action: "subscription" }, @routes.recognize_path("/account/subscription", method: :get))
+ assert_equal({ controller: "account", action: "billing" }, @routes.recognize_path("/account/billing", method: :get))
- assert_equal({page_id: "1", controller: "notes", action: "index"}, @routes.recognize_path("/pages/1/notes", method: :get))
- assert_equal({page_id: "1", controller: "notes", action: "list"}, @routes.recognize_path("/pages/1/notes/list", method: :get))
- assert_equal({page_id: "1", controller: "notes", action: "show", id: "2"}, @routes.recognize_path("/pages/1/notes/show/2", method: :get))
+ assert_equal({ page_id: "1", controller: "notes", action: "index" }, @routes.recognize_path("/pages/1/notes", method: :get))
+ assert_equal({ page_id: "1", controller: "notes", action: "list" }, @routes.recognize_path("/pages/1/notes/list", method: :get))
+ assert_equal({ page_id: "1", controller: "notes", action: "show", id: "2" }, @routes.recognize_path("/pages/1/notes/show/2", method: :get))
- assert_equal({controller: "posts", action: "ping"}, @routes.recognize_path("/posts/ping", method: :get))
- assert_equal({controller: "posts", action: "index"}, @routes.recognize_path("/posts", method: :get))
- assert_equal({controller: "posts", action: "index"}, @routes.recognize_path("/posts/index", method: :get))
- assert_equal({controller: "posts", action: "show"}, @routes.recognize_path("/posts/show", method: :get))
- assert_equal({controller: "posts", action: "show", id: "1"}, @routes.recognize_path("/posts/show/1", method: :get))
- assert_equal({controller: "posts", action: "create"}, @routes.recognize_path("/posts/create", method: :post))
+ assert_equal({ controller: "posts", action: "ping" }, @routes.recognize_path("/posts/ping", method: :get))
+ assert_equal({ controller: "posts", action: "index" }, @routes.recognize_path("/posts", method: :get))
+ assert_equal({ controller: "posts", action: "index" }, @routes.recognize_path("/posts/index", method: :get))
+ assert_equal({ controller: "posts", action: "show" }, @routes.recognize_path("/posts/show", method: :get))
+ assert_equal({ controller: "posts", action: "show", id: "1" }, @routes.recognize_path("/posts/show/1", method: :get))
+ assert_equal({ controller: "posts", action: "create" }, @routes.recognize_path("/posts/create", method: :post))
- assert_equal({controller: "geocode", action: "show", postalcode: "hx12-1az"}, @routes.recognize_path("/ignorecase/geocode/hx12-1az"))
- assert_equal({controller: "geocode", action: "show", postalcode: "hx12-1AZ"}, @routes.recognize_path("/ignorecase/geocode/hx12-1AZ"))
- assert_equal({controller: "geocode", action: "show", postalcode: "12345-1234"}, @routes.recognize_path("/extended/geocode/12345-1234"))
- assert_equal({controller: "geocode", action: "show", postalcode: "12345"}, @routes.recognize_path("/extended/geocode/12345"))
+ assert_equal({ controller: "geocode", action: "show", postalcode: "hx12-1az" }, @routes.recognize_path("/ignorecase/geocode/hx12-1az"))
+ assert_equal({ controller: "geocode", action: "show", postalcode: "hx12-1AZ" }, @routes.recognize_path("/ignorecase/geocode/hx12-1AZ"))
+ assert_equal({ controller: "geocode", action: "show", postalcode: "12345-1234" }, @routes.recognize_path("/extended/geocode/12345-1234"))
+ assert_equal({ controller: "geocode", action: "show", postalcode: "12345" }, @routes.recognize_path("/extended/geocode/12345"))
- assert_equal({controller: "news", action: "index" }, @routes.recognize_path("/", method: :get))
- assert_equal({controller: "news", action: "index", format: "rss"}, @routes.recognize_path("/news.rss", method: :get))
+ assert_equal({ controller: "news", action: "index" }, @routes.recognize_path("/", method: :get))
+ assert_equal({ controller: "news", action: "index", format: "rss" }, @routes.recognize_path("/news.rss", method: :get))
assert_raise(ActionController::RoutingError) { @routes.recognize_path("/none", method: :get) }
end
@@ -2059,25 +2059,25 @@ class RackMountIntegrationTests < ActiveSupport::TestCase
end
def test_extras
- params = {controller: "people"}
+ params = { controller: "people" }
assert_equal [], @routes.extra_keys(params)
- assert_equal({controller: "people", action: "index"}, params)
+ assert_equal({ controller: "people", action: "index" }, params)
- params = {controller: "people", foo: "bar"}
+ params = { controller: "people", foo: "bar" }
assert_equal [:foo], @routes.extra_keys(params)
- assert_equal({controller: "people", action: "index", foo: "bar"}, params)
+ assert_equal({ controller: "people", action: "index", foo: "bar" }, params)
- params = {controller: "people", action: "create", person: { name: "Josh"}}
+ params = { controller: "people", action: "create", person: { name: "Josh" } }
assert_equal [:person], @routes.extra_keys(params)
- assert_equal({controller: "people", action: "create", person: { name: "Josh"}}, params)
+ assert_equal({ controller: "people", action: "create", person: { name: "Josh" } }, params)
end
def test_unicode_path
- assert_equal({controller: "news", action: "index"}, @routes.recognize_path(URI.parser.escape("こんにちは/世界"), method: :get))
+ assert_equal({ controller: "news", action: "index" }, @routes.recognize_path(URI.parser.escape("こんにちは/世界"), method: :get))
end
def test_downcased_unicode_path
- assert_equal({controller: "news", action: "index"}, @routes.recognize_path(URI.parser.escape("こんにちは/世界").downcase, method: :get))
+ assert_equal({ controller: "news", action: "index" }, @routes.recognize_path(URI.parser.escape("こんにちは/世界").downcase, method: :get))
end
private
diff --git a/actionpack/test/controller/send_file_test.rb b/actionpack/test/controller/send_file_test.rb
index 3fb0ee8059..25420ead3b 100644
--- a/actionpack/test/controller/send_file_test.rb
+++ b/actionpack/test/controller/send_file_test.rb
@@ -192,7 +192,7 @@ class SendFileTest < ActionController::TestCase
end
def test_send_file_without_content_disposition_header
- @controller.options = {disposition: nil}
+ @controller.options = { disposition: nil }
process("data")
assert_nil @controller.headers["Content-Disposition"]
end
diff --git a/actionpack/test/controller/test_case_test.rb b/actionpack/test/controller/test_case_test.rb
index 45bc770e86..2d78fc71a9 100644
--- a/actionpack/test/controller/test_case_test.rb
+++ b/actionpack/test/controller/test_case_test.rb
@@ -239,7 +239,7 @@ XML
def test_document_body_and_params_with_post
post :test_params, params: { id: 1 }
- assert_equal({"id"=>"1", "controller"=>"test_case_test/test", "action"=>"test_params"}, ::JSON.parse(@response.body))
+ assert_equal({ "id"=>"1", "controller"=>"test_case_test/test", "action"=>"test_params" }, ::JSON.parse(@response.body))
end
def test_document_body_with_post
@@ -525,15 +525,15 @@ XML
end
def test_query_param_named_action
- get :test_query_parameters, params: {action: "foobar"}
+ get :test_query_parameters, params: { action: "foobar" }
parsed_params = JSON.parse(@response.body)
- assert_equal({"action" => "foobar"}, parsed_params)
+ assert_equal({ "action" => "foobar" }, parsed_params)
end
def test_request_param_named_action
- post :test_request_parameters, params: {action: "foobar"}
+ post :test_request_parameters, params: { action: "foobar" }
parsed_params = eval(@response.body)
- assert_equal({"action" => "foobar"}, parsed_params)
+ assert_equal({ "action" => "foobar" }, parsed_params)
end
def test_kwarg_params_passing_with_session_and_flash
@@ -548,8 +548,8 @@ XML
parsed_params = ::JSON.parse(@response.body)
assert_equal(
- {"controller" => "test_case_test/test", "action" => "test_params",
- "page" => {"name" => "Page name", "month" => "4", "year" => "2004", "day" => "6"}},
+ { "controller" => "test_case_test/test", "action" => "test_params",
+ "page" => { "name" => "Page name", "month" => "4", "year" => "2004", "day" => "6" } },
parsed_params
)
@@ -563,8 +563,8 @@ XML
}
parsed_params = ::JSON.parse(@response.body)
assert_equal(
- {"controller" => "test_case_test/test", "action" => "test_params",
- "page" => {"name" => "Page name", "month" => "4", "year" => "2004", "day" => "6"}},
+ { "controller" => "test_case_test/test", "action" => "test_params",
+ "page" => { "name" => "Page name", "month" => "4", "year" => "2004", "day" => "6" } },
parsed_params
)
end
@@ -573,7 +573,7 @@ XML
get :test_params, params: { format: "json", count: 999 }
parsed_params = ::JSON.parse(@response.body)
assert_equal(
- {"controller" => "test_case_test/test", "action" => "test_params",
+ { "controller" => "test_case_test/test", "action" => "test_params",
"format" => "json", "count" => "999" },
parsed_params
)
@@ -583,7 +583,7 @@ XML
get :test_params, params: { format: "json", id: 1 }
parsed_params = ::JSON.parse(@response.body)
assert_equal(
- {"controller" => "test_case_test/test", "action" => "test_params",
+ { "controller" => "test_case_test/test", "action" => "test_params",
"format" => "json", "id" => "1" },
parsed_params
)
@@ -593,7 +593,7 @@ XML
assert_deprecated { get :test_params, format: "json", id: 1 }
parsed_params = ::JSON.parse(@response.body)
assert_equal(
- {"controller" => "test_case_test/test", "action" => "test_params",
+ { "controller" => "test_case_test/test", "action" => "test_params",
"format" => "json", "id" => "1" },
parsed_params
)
@@ -607,8 +607,8 @@ XML
end
parsed_params = ::JSON.parse(@response.body)
assert_equal(
- {"controller" => "test_case_test/test", "action" => "test_params",
- "frozen" => "icy", "frozens" => ["icy"], "deepfreeze" => { "frozen" => "icy" }},
+ { "controller" => "test_case_test/test", "action" => "test_params",
+ "frozen" => "icy", "frozens" => ["icy"], "deepfreeze" => { "frozen" => "icy" } },
parsed_params
)
end
@@ -670,7 +670,7 @@ XML
end
def test_deprecared_id_converted_to_string
- assert_deprecated { get :test_params, id: 20, foo: Object.new}
+ assert_deprecated { get :test_params, id: 20, foo: Object.new }
assert_kind_of String, @request.path_parameters[:id]
end
@@ -731,13 +731,13 @@ XML
def test_deprecated_xhr_with_params
assert_deprecated { xhr :get, :test_params, params: { id: 1 } }
- assert_equal({"id"=>"1", "controller"=>"test_case_test/test", "action"=>"test_params"}, ::JSON.parse(@response.body))
+ assert_equal({ "id"=>"1", "controller"=>"test_case_test/test", "action"=>"test_params" }, ::JSON.parse(@response.body))
end
def test_xhr_with_params
get :test_params, params: { id: 1 }, xhr: true
- assert_equal({"id"=>"1", "controller"=>"test_case_test/test", "action"=>"test_params"}, ::JSON.parse(@response.body))
+ assert_equal({ "id"=>"1", "controller"=>"test_case_test/test", "action"=>"test_params" }, ::JSON.parse(@response.body))
end
def test_xhr_with_session
@@ -856,10 +856,10 @@ XML
def test_multiple_mixed_method_process_should_scrub_rack_input
post :test_params, params: { id: 1, foo: "an foo" }
- assert_equal({"id"=>"1", "foo" => "an foo", "controller"=>"test_case_test/test", "action"=>"test_params"}, ::JSON.parse(@response.body))
+ assert_equal({ "id"=>"1", "foo" => "an foo", "controller"=>"test_case_test/test", "action"=>"test_params" }, ::JSON.parse(@response.body))
get :test_params, params: { bar: "an bar" }
- assert_equal({"bar"=>"an bar", "controller"=>"test_case_test/test", "action"=>"test_params"}, ::JSON.parse(@response.body))
+ assert_equal({ "bar"=>"an bar", "controller"=>"test_case_test/test", "action"=>"test_params" }, ::JSON.parse(@response.body))
end
%w(controller response request).each do |variable|
@@ -1208,7 +1208,7 @@ class RoutingDefaultsTest < ActionController::TestCase
end
def test_route_option_can_be_passed_via_process
- get :post, params: { id: 1, bucket_type: "post"}
+ get :post, params: { id: 1, bucket_type: "post" }
assert_equal "/posts/1", @response.body
end
diff --git a/actionpack/test/controller/url_for_integration_test.rb b/actionpack/test/controller/url_for_integration_test.rb
index fc746add9b..c7ea6c5ef6 100644
--- a/actionpack/test/controller/url_for_integration_test.rb
+++ b/actionpack/test/controller/url_for_integration_test.rb
@@ -78,7 +78,7 @@ module ActionPack
["/admin/users",[ { controller: "admin/users", action: "index" }]],
["/admin/users",[ { action: "index" }, { controller: "admin/users", action: "index" }, "/admin/users"]],
["/admin/users",[ { controller: "users", action: "index" }, { controller: "admin/accounts", action: "show", id: "1" }, "/admin/accounts/show/1"]],
- ["/people",[ { controller: "/people", action: "index" }, {controller: "admin/accounts", action: "foo", id: "bar"}, "/admin/accounts/foo/bar"]],
+ ["/people",[ { controller: "/people", action: "index" }, { controller: "admin/accounts", action: "foo", id: "bar" }, "/admin/accounts/foo/bar"]],
["/admin/posts",[ { controller: "admin/posts" }]],
["/admin/posts/new",[ { controller: "admin/posts", action: "new" }]],
@@ -124,7 +124,7 @@ module ActionPack
["/project",[ { controller: "project", action: "index" }]],
["/projects/1",[ { controller: "project", action: "index", project_id: "1" }]],
- ["/projects/1",[ { controller: "project", action: "index"}, {project_id: "1", controller: "project", action: "index" }, "/projects/1"]],
+ ["/projects/1",[ { controller: "project", action: "index" }, { project_id: "1", controller: "project", action: "index" }, "/projects/1"]],
["/projects/1",[ { use_route: "project", controller: "project", action: "index", project_id: "1" }]],
["/projects/1",[ { use_route: "project", controller: "project", action: "index" }, { controller: "project", action: "index", project_id: "1" }, "/projects/1"]],
@@ -164,11 +164,11 @@ module ActionPack
["/posts/show/1",[ { controller: "posts", action: "show", id: "1", format: "" }]],
["/posts",[ { controller: "posts" }]],
["/posts",[ { controller: "posts", action: "index" }]],
- ["/posts/create",[ { action: "create" }, {day: nil, month: nil, controller: "posts", action: "show_date"}, "/blog"]],
+ ["/posts/create",[ { action: "create" }, { day: nil, month: nil, controller: "posts", action: "show_date" }, "/blog"]],
["/posts?foo=bar",[ { controller: "posts", foo: "bar" }]],
["/posts?foo%5B%5D=bar&foo%5B%5D=baz", [{ controller: "posts", foo: ["bar", "baz"] }]],
["/posts?page=2", [{ controller: "posts", page: 2 }]],
- ["/posts?q%5Bfoo%5D%5Ba%5D=b", [{ controller: "posts", q: { foo: { a: "b"}} }]],
+ ["/posts?q%5Bfoo%5D%5Ba%5D=b", [{ controller: "posts", q: { foo: { a: "b" } } }]],
["/news.rss", [{ controller: "news", action: "index", format: "rss" }]],
].each_with_index do |(url, params), i|
diff --git a/actionpack/test/controller/url_for_test.rb b/actionpack/test/controller/url_for_test.rb
index ad4acf3462..8d7190365d 100644
--- a/actionpack/test/controller/url_for_test.rb
+++ b/actionpack/test/controller/url_for_test.rb
@@ -222,19 +222,19 @@ module AbstractController
def test_trailing_slash
add_host!
- options = {controller: "foo", trailing_slash: true, action: "bar", id: "33"}
+ options = { controller: "foo", trailing_slash: true, action: "bar", id: "33" }
assert_equal("http://www.basecamphq.com/foo/bar/33/", W.new.url_for(options) )
end
def test_trailing_slash_with_protocol
add_host!
- options = { trailing_slash: true,protocol: "https", controller: "foo", action: "bar", id: "33"}
+ 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"))
end
def test_trailing_slash_with_only_path
- options = {controller: "foo", trailing_slash: true}
+ 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))
@@ -242,7 +242,7 @@ module AbstractController
end
def test_trailing_slash_with_anchor
- options = {trailing_slash: true, controller: "foo", action: "bar", id: "33", only_path: true, anchor: "chapter7"}
+ 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"))
end
@@ -250,8 +250,8 @@ module AbstractController
def test_trailing_slash_with_params
url = W.new.url_for(trailing_slash: true, only_path: true, controller: "cont", action: "act", p1: "cafe", p2: "link")
params = extract_params(url)
- assert_equal({p1: "cafe"}.to_query, params[0])
- assert_equal({p2: "link"}.to_query, params[1])
+ assert_equal({ p1: "cafe" }.to_query, params[0])
+ assert_equal({ p2: "link" }.to_query, params[1])
end
def test_relative_url_root_is_respected
@@ -348,40 +348,40 @@ module AbstractController
def test_two_parameters
url = W.new.url_for(only_path: true, controller: "c", action: "a", p1: "X1", p2: "Y2")
params = extract_params(url)
- assert_equal({p1: "X1"}.to_query, params[0])
- assert_equal({p2: "Y2"}.to_query, params[1])
+ assert_equal({ p1: "X1" }.to_query, params[0])
+ assert_equal({ p2: "Y2" }.to_query, params[1])
end
def test_hash_parameter
- url = W.new.url_for(only_path: true, controller: "c", action: "a", query: {name: "Bob", category: "prof"})
+ url = W.new.url_for(only_path: true, controller: "c", action: "a", query: { name: "Bob", category: "prof" })
params = extract_params(url)
- assert_equal({"query[category]" => "prof"}.to_query, params[0])
- assert_equal({"query[name]" => "Bob"}.to_query, params[1])
+ assert_equal({ "query[category]" => "prof" }.to_query, params[0])
+ assert_equal({ "query[name]" => "Bob" }.to_query, params[1])
end
def test_array_parameter
url = W.new.url_for(only_path: true, controller: "c", action: "a", query: ["Bob", "prof"])
params = extract_params(url)
- assert_equal({"query[]" => "Bob"}.to_query, params[0])
- assert_equal({"query[]" => "prof"}.to_query, params[1])
+ assert_equal({ "query[]" => "Bob" }.to_query, params[0])
+ assert_equal({ "query[]" => "prof" }.to_query, params[1])
end
def test_hash_recursive_parameters
- url = W.new.url_for(only_path: true, controller: "c", action: "a", query: {person: {name: "Bob", position: "prof"}, hobby: "piercing"})
+ url = W.new.url_for(only_path: true, controller: "c", action: "a", query: { person: { name: "Bob", position: "prof" }, hobby: "piercing" })
params = extract_params(url)
- assert_equal({"query[hobby]" => "piercing"}.to_query, params[0])
- assert_equal({"query[person][name]" => "Bob" }.to_query, params[1])
- assert_equal({"query[person][position]" => "prof" }.to_query, params[2])
+ assert_equal({ "query[hobby]" => "piercing" }.to_query, params[0])
+ assert_equal({ "query[person][name]" => "Bob" }.to_query, params[1])
+ assert_equal({ "query[person][position]" => "prof" }.to_query, params[2])
end
def test_hash_recursive_and_array_parameters
- url = W.new.url_for(only_path: true, controller: "c", action: "a", id: 101, query: {person: {name: "Bob", position: ["prof", "art director"]}, hobby: "piercing"})
+ url = W.new.url_for(only_path: true, controller: "c", action: "a", id: 101, query: { person: { name: "Bob", position: ["prof", "art director"] }, hobby: "piercing" })
assert_match(%r(^/c/a/101), url)
params = extract_params(url)
- assert_equal({"query[hobby]" => "piercing" }.to_query, params[0])
- assert_equal({"query[person][name]" => "Bob" }.to_query, params[1])
- assert_equal({"query[person][position][]" => "art director"}.to_query, params[2])
- assert_equal({"query[person][position][]" => "prof" }.to_query, params[3])
+ assert_equal({ "query[hobby]" => "piercing" }.to_query, params[0])
+ assert_equal({ "query[person][name]" => "Bob" }.to_query, params[1])
+ assert_equal({ "query[person][position][]" => "art director" }.to_query, params[2])
+ assert_equal({ "query[person][position][]" => "prof" }.to_query, params[3])
end
def test_url_action_controller_parameters
@@ -407,7 +407,7 @@ module AbstractController
kls.default_url_options[:host] = "www.basecamphq.com"
controller = kls.new
- params = {action: :index, controller: :posts, format: :xml}
+ params = { action: :index, controller: :posts, format: :xml }
assert_equal("http://www.basecamphq.com/posts.xml", controller.send(:url_for, params))
params[:format] = nil
assert_equal("http://www.basecamphq.com/", controller.send(:url_for, params))
diff --git a/actionpack/test/controller/url_rewriter_test.rb b/actionpack/test/controller/url_rewriter_test.rb
index d64ff4d6ce..a055e6d177 100644
--- a/actionpack/test/controller/url_rewriter_test.rb
+++ b/actionpack/test/controller/url_rewriter_test.rb
@@ -79,7 +79,7 @@ class UrlRewriterTests < ActionController::TestCase
end
def test_trailing_slash
- options = {controller: "foo", action: "bar", id: "3", only_path: true}
+ 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)