aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/dispatch
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack/test/dispatch')
-rw-r--r--actionpack/test/dispatch/cookies_test.rb30
-rw-r--r--actionpack/test/dispatch/mapper_test.rb30
-rw-r--r--actionpack/test/dispatch/middleware_stack_test.rb4
-rw-r--r--actionpack/test/dispatch/mount_test.rb12
-rw-r--r--actionpack/test/dispatch/prefix_generation_test.rb120
-rw-r--r--actionpack/test/dispatch/rack_cache_test.rb2
-rw-r--r--actionpack/test/dispatch/reloader_test.rb2
-rw-r--r--actionpack/test/dispatch/request/json_params_parsing_test.rb6
-rw-r--r--actionpack/test/dispatch/request/multipart_params_parsing_test.rb4
-rw-r--r--actionpack/test/dispatch/request/query_string_parsing_test.rb4
-rw-r--r--actionpack/test/dispatch/request/session_test.rb2
-rw-r--r--actionpack/test/dispatch/request_id_test.rb2
-rw-r--r--actionpack/test/dispatch/request_test.rb30
-rw-r--r--actionpack/test/dispatch/response_test.rb16
-rw-r--r--actionpack/test/dispatch/routing/inspector_test.rb18
-rw-r--r--actionpack/test/dispatch/routing/ipv6_redirect_test.rb8
-rw-r--r--actionpack/test/dispatch/routing_assertions_test.rb66
-rw-r--r--actionpack/test/dispatch/routing_test.rb816
-rw-r--r--actionpack/test/dispatch/session/cache_store_test.rb4
-rw-r--r--actionpack/test/dispatch/session/cookie_store_test.rb20
-rw-r--r--actionpack/test/dispatch/session/mem_cache_store_test.rb4
-rw-r--r--actionpack/test/dispatch/test_request_test.rb2
-rw-r--r--actionpack/test/dispatch/uploaded_file_test.rb34
-rw-r--r--actionpack/test/dispatch/url_generation_test.rb6
24 files changed, 621 insertions, 621 deletions
diff --git a/actionpack/test/dispatch/cookies_test.rb b/actionpack/test/dispatch/cookies_test.rb
index eb15772133..06a54591b8 100644
--- a/actionpack/test/dispatch/cookies_test.rb
+++ b/actionpack/test/dispatch/cookies_test.rb
@@ -100,7 +100,7 @@ class CookiesTest < ActionController::TestCase
end
def authenticate_for_fourteen_days_with_symbols
- cookies[:user_name] = { :value => "david", :expires => Time.utc(2005, 10, 10,5) }
+ cookies[:user_name] = { value: "david", expires: Time.utc(2005, 10, 10,5) }
head :ok
end
@@ -123,17 +123,17 @@ class CookiesTest < ActionController::TestCase
alias delete_cookie logout
def delete_cookie_with_path
- cookies.delete("user_name", :path => "/beaten")
+ cookies.delete("user_name", path: "/beaten")
head :ok
end
def authenticate_with_http_only
- cookies["user_name"] = { :value => "david", :httponly => true }
+ cookies["user_name"] = { value: "david", httponly: true }
head :ok
end
def authenticate_with_secure
- cookies["user_name"] = { :value => "david", :secure => true }
+ cookies["user_name"] = { value: "david", secure: true }
head :ok
end
@@ -205,47 +205,47 @@ class CookiesTest < ActionController::TestCase
def delete_and_set_cookie
cookies.delete :user_name
- cookies[:user_name] = { :value => "david", :expires => Time.utc(2005, 10, 10,5) }
+ cookies[:user_name] = { value: "david", expires: Time.utc(2005, 10, 10,5) }
head :ok
end
def set_cookie_with_domain
- cookies[:user_name] = {:value => "rizwanreza", :domain => :all}
+ cookies[:user_name] = {value: "rizwanreza", domain: :all}
head :ok
end
def set_cookie_with_domain_all_as_string
- cookies[:user_name] = {:value => "rizwanreza", :domain => "all"}
+ cookies[:user_name] = {value: "rizwanreza", domain: "all"}
head :ok
end
def delete_cookie_with_domain
- cookies.delete(:user_name, :domain => :all)
+ cookies.delete(:user_name, domain: :all)
head :ok
end
def delete_cookie_with_domain_all_as_string
- cookies.delete(:user_name, :domain => "all")
+ cookies.delete(:user_name, domain: "all")
head :ok
end
def set_cookie_with_domain_and_tld
- cookies[:user_name] = {:value => "rizwanreza", :domain => :all, :tld_length => 2}
+ cookies[:user_name] = {value: "rizwanreza", domain: :all, tld_length: 2}
head :ok
end
def delete_cookie_with_domain_and_tld
- cookies.delete(:user_name, :domain => :all, :tld_length => 2)
+ cookies.delete(:user_name, domain: :all, tld_length: 2)
head :ok
end
def set_cookie_with_domains
- cookies[:user_name] = {:value => "rizwanreza", :domain => %w(example1.com example2.com .example3.com)}
+ cookies[:user_name] = {value: "rizwanreza", domain: %w(example1.com example2.com .example3.com)}
head :ok
end
def delete_cookie_with_domains
- cookies.delete(:user_name, :domain => %w(example1.com example2.com .example3.com))
+ cookies.delete(:user_name, domain: %w(example1.com example2.com .example3.com))
head :ok
end
@@ -393,8 +393,8 @@ class CookiesTest < ActionController::TestCase
def test_deleted_cookie_predicate_with_mismatching_options
cookies[:user_name] = "Joe"
- cookies.delete("user_name", :path => "/path")
- assert_equal false, cookies.deleted?("user_name", :path => "/different")
+ cookies.delete("user_name", path: "/path")
+ assert_equal false, cookies.deleted?("user_name", path: "/different")
end
def test_cookies_persist_throughout_request
diff --git a/actionpack/test/dispatch/mapper_test.rb b/actionpack/test/dispatch/mapper_test.rb
index 3c3bb17072..8d2699fef6 100644
--- a/actionpack/test/dispatch/mapper_test.rb
+++ b/actionpack/test/dispatch/mapper_test.rb
@@ -50,15 +50,15 @@ module ActionDispatch
fakeset = FakeSet.new
mapper = Mapper.new fakeset
assert_raises(ArgumentError) do
- mapper.match "/", :to => "posts#index", :as => :main
+ mapper.match "/", to: "posts#index", as: :main
end
end
def test_unscoped_formatted
fakeset = FakeSet.new
mapper = Mapper.new fakeset
- mapper.get "/foo", :to => "posts#index", :as => :main, :format => true
- assert_equal({:controller=>"posts", :action=>"index"},
+ mapper.get "/foo", to: "posts#index", as: :main, format: true
+ assert_equal({controller: "posts", action: "index"},
fakeset.defaults.first)
assert_equal "/foo.:format", fakeset.asts.first.to_s
end
@@ -67,9 +67,9 @@ module ActionDispatch
fakeset = FakeSet.new
mapper = Mapper.new fakeset
mapper.scope(format: true) do
- mapper.get "/foo", :to => "posts#index", :as => :main
+ mapper.get "/foo", to: "posts#index", as: :main
end
- assert_equal({:controller=>"posts", :action=>"index"},
+ assert_equal({controller: "posts", action: "index"},
fakeset.defaults.first)
assert_equal "/foo.:format", fakeset.asts.first.to_s
end
@@ -78,9 +78,9 @@ module ActionDispatch
fakeset = FakeSet.new
mapper = Mapper.new fakeset
mapper.scope(omg: :awesome) do
- mapper.get "/", :to => "posts#index", :as => :main
+ mapper.get "/", to: "posts#index", as: :main
end
- assert_equal({:omg=>:awesome, :controller=>"posts", :action=>"index"},
+ assert_equal({omg: :awesome, controller: "posts", action: "index"},
fakeset.defaults.first)
assert_equal("GET", fakeset.routes.first.verb)
end
@@ -97,7 +97,7 @@ module ActionDispatch
fakeset = FakeSet.new
mapper = Mapper.new fakeset
mapper.scope(via: :put) do
- mapper.match "/", :to => "posts#index", :as => :main
+ mapper.match "/", to: "posts#index", as: :main
end
assert_equal("PUT", fakeset.routes.first.verb)
end
@@ -117,7 +117,7 @@ module ActionDispatch
def test_map_slash
fakeset = FakeSet.new
mapper = Mapper.new fakeset
- mapper.get "/", :to => "posts#index", :as => :main
+ mapper.get "/", to: "posts#index", as: :main
assert_equal "/", fakeset.asts.first.to_s
end
@@ -126,14 +126,14 @@ module ActionDispatch
mapper = Mapper.new fakeset
# FIXME: is this a desired behavior?
- mapper.get "/one/two/", :to => "posts#index", :as => :main
+ mapper.get "/one/two/", to: "posts#index", as: :main
assert_equal "/one/two(.:format)", fakeset.asts.first.to_s
end
def test_map_wildcard
fakeset = FakeSet.new
mapper = Mapper.new fakeset
- mapper.get "/*path", :to => "pages#show"
+ mapper.get "/*path", to: "pages#show"
assert_equal "/*path(.:format)", fakeset.asts.first.to_s
assert_equal(/.+?/, fakeset.requirements.first[:path])
end
@@ -141,7 +141,7 @@ module ActionDispatch
def test_map_wildcard_with_other_element
fakeset = FakeSet.new
mapper = Mapper.new fakeset
- mapper.get "/*path/foo/:bar", :to => "pages#show"
+ mapper.get "/*path/foo/:bar", to: "pages#show"
assert_equal "/*path/foo/:bar(.:format)", fakeset.asts.first.to_s
assert_equal(/.+?/, fakeset.requirements.first[:path])
end
@@ -149,7 +149,7 @@ module ActionDispatch
def test_map_wildcard_with_multiple_wildcard
fakeset = FakeSet.new
mapper = Mapper.new fakeset
- mapper.get "/*foo/*bar", :to => "pages#show"
+ mapper.get "/*foo/*bar", to: "pages#show"
assert_equal "/*foo/*bar(.:format)", fakeset.asts.first.to_s
assert_equal(/.+?/, fakeset.requirements.first[:foo])
assert_equal(/.+?/, fakeset.requirements.first[:bar])
@@ -158,7 +158,7 @@ module ActionDispatch
def test_map_wildcard_with_format_false
fakeset = FakeSet.new
mapper = Mapper.new fakeset
- mapper.get "/*path", :to => "pages#show", :format => false
+ mapper.get "/*path", to: "pages#show", format: false
assert_equal "/*path", fakeset.asts.first.to_s
assert_nil fakeset.requirements.first[:path]
end
@@ -166,7 +166,7 @@ module ActionDispatch
def test_map_wildcard_with_format_true
fakeset = FakeSet.new
mapper = Mapper.new fakeset
- mapper.get "/*path", :to => "pages#show", :format => true
+ mapper.get "/*path", to: "pages#show", format: true
assert_equal "/*path.:format", fakeset.asts.first.to_s
end
diff --git a/actionpack/test/dispatch/middleware_stack_test.rb b/actionpack/test/dispatch/middleware_stack_test.rb
index a906ddc80f..b00488edd5 100644
--- a/actionpack/test/dispatch/middleware_stack_test.rb
+++ b/actionpack/test/dispatch/middleware_stack_test.rb
@@ -59,10 +59,10 @@ class MiddlewareStackTest < ActiveSupport::TestCase
test "use should push middleware class with arguments onto the stack" do
assert_difference "@stack.size" do
- @stack.use BazMiddleware, true, :foo => "bar"
+ @stack.use BazMiddleware, true, foo: "bar"
end
assert_equal BazMiddleware, @stack.last.klass
- assert_equal([true, {:foo => "bar"}], @stack.last.args)
+ assert_equal([true, {foo: "bar"}], @stack.last.args)
end
test "use should push middleware class with block arguments onto the stack" do
diff --git a/actionpack/test/dispatch/mount_test.rb b/actionpack/test/dispatch/mount_test.rb
index f4956526fc..179b65b236 100644
--- a/actionpack/test/dispatch/mount_test.rb
+++ b/actionpack/test/dispatch/mount_test.rb
@@ -24,21 +24,21 @@ class TestRoutingMount < ActionDispatch::IntegrationTest
[200, {"Content-Type" => "text/html"}, ["#{env["SCRIPT_NAME"]} -- #{env["PATH_INFO"]}"]]
}
- mount SprocketsApp, :at => "/sprockets"
+ mount SprocketsApp, at: "/sprockets"
mount SprocketsApp => "/shorthand"
- mount SinatraLikeApp, :at => "/fakeengine", :as => :fake
- mount SinatraLikeApp, :at => "/getfake", :via => :get
+ mount SinatraLikeApp, at: "/fakeengine", as: :fake
+ mount SinatraLikeApp, at: "/getfake", via: :get
scope "/its_a" do
- mount SprocketsApp, :at => "/sprocket"
+ mount SprocketsApp, at: "/sprocket"
end
resources :users do
- mount AppWithRoutes, :at => "/fakeengine", :as => :fake_mounted_at_resource
+ mount AppWithRoutes, at: "/fakeengine", as: :fake_mounted_at_resource
end
- mount SprocketsApp, :at => "/", :via => :get
+ mount SprocketsApp, at: "/", via: :get
end
APP = RoutedRackApp.new Router
diff --git a/actionpack/test/dispatch/prefix_generation_test.rb b/actionpack/test/dispatch/prefix_generation_test.rb
index ef2dc170f5..ea11a943f2 100644
--- a/actionpack/test/dispatch/prefix_generation_test.rb
+++ b/actionpack/test/dispatch/prefix_generation_test.rb
@@ -26,42 +26,42 @@ module TestGenerationPrefix
class BlogEngine < Rails::Engine
routes.draw do
- get "/posts/:id", :to => "inside_engine_generating#show", :as => :post
- get "/posts", :to => "inside_engine_generating#index", :as => :posts
- get "/url_to_application", :to => "inside_engine_generating#url_to_application"
- get "/polymorphic_path_for_engine", :to => "inside_engine_generating#polymorphic_path_for_engine"
- get "/conflicting_url", :to => "inside_engine_generating#conflicting"
- get "/foo", :to => "never#invoked", :as => :named_helper_that_should_be_invoked_only_in_respond_to_test
-
- get "/relative_path_root", :to => redirect("")
- get "/relative_path_redirect", :to => redirect("foo")
- get "/relative_option_root", :to => redirect(:path => "")
- get "/relative_option_redirect", :to => redirect(:path => "foo")
- get "/relative_custom_root", :to => redirect { |params, request| "" }
- get "/relative_custom_redirect", :to => redirect { |params, request| "foo" }
-
- get "/absolute_path_root", :to => redirect("/")
- get "/absolute_path_redirect", :to => redirect("/foo")
- get "/absolute_option_root", :to => redirect(:path => "/")
- get "/absolute_option_redirect", :to => redirect(:path => "/foo")
- get "/absolute_custom_root", :to => redirect { |params, request| "/" }
- get "/absolute_custom_redirect", :to => redirect { |params, request| "/foo" }
+ get "/posts/:id", to: "inside_engine_generating#show", as: :post
+ get "/posts", to: "inside_engine_generating#index", as: :posts
+ get "/url_to_application", to: "inside_engine_generating#url_to_application"
+ get "/polymorphic_path_for_engine", to: "inside_engine_generating#polymorphic_path_for_engine"
+ get "/conflicting_url", to: "inside_engine_generating#conflicting"
+ get "/foo", to: "never#invoked", as: :named_helper_that_should_be_invoked_only_in_respond_to_test
+
+ get "/relative_path_root", to: redirect("")
+ get "/relative_path_redirect", to: redirect("foo")
+ get "/relative_option_root", to: redirect(path: "")
+ get "/relative_option_redirect", to: redirect(path: "foo")
+ get "/relative_custom_root", to: redirect { |params, request| "" }
+ get "/relative_custom_redirect", to: redirect { |params, request| "foo" }
+
+ get "/absolute_path_root", to: redirect("/")
+ get "/absolute_path_redirect", to: redirect("/foo")
+ get "/absolute_option_root", to: redirect(path: "/")
+ get "/absolute_option_redirect", to: redirect(path: "/foo")
+ get "/absolute_custom_root", to: redirect { |params, request| "/" }
+ get "/absolute_custom_redirect", to: redirect { |params, request| "/foo" }
end
end
class RailsApplication < Rails::Engine
routes.draw do
- scope "/:omg", :omg => "awesome" do
+ scope "/:omg", omg: "awesome" do
mount BlogEngine => "/blog", :as => "blog_engine"
end
- get "/posts/:id", :to => "outside_engine_generating#post", :as => :post
- get "/generate", :to => "outside_engine_generating#index"
- get "/polymorphic_path_for_app", :to => "outside_engine_generating#polymorphic_path_for_app"
- get "/polymorphic_path_for_engine", :to => "outside_engine_generating#polymorphic_path_for_engine"
- get "/polymorphic_with_url_for", :to => "outside_engine_generating#polymorphic_with_url_for"
- get "/conflicting_url", :to => "outside_engine_generating#conflicting"
- get "/ivar_usage", :to => "outside_engine_generating#ivar_usage"
- root :to => "outside_engine_generating#index"
+ get "/posts/:id", to: "outside_engine_generating#post", as: :post
+ get "/generate", to: "outside_engine_generating#index"
+ get "/polymorphic_path_for_app", to: "outside_engine_generating#polymorphic_path_for_app"
+ get "/polymorphic_path_for_engine", to: "outside_engine_generating#polymorphic_path_for_engine"
+ get "/polymorphic_with_url_for", to: "outside_engine_generating#polymorphic_with_url_for"
+ get "/conflicting_url", to: "outside_engine_generating#conflicting"
+ get "/ivar_usage", to: "outside_engine_generating#ivar_usage"
+ root to: "outside_engine_generating#index"
end
end
@@ -81,9 +81,9 @@ module TestGenerationPrefix
end
def url_to_application
- path = main_app.url_for(:controller => "outside_engine_generating",
- :action => "index",
- :only_path => true)
+ path = main_app.url_for(controller: "outside_engine_generating",
+ action: "index",
+ only_path: true)
render plain: path
end
@@ -238,7 +238,7 @@ module TestGenerationPrefix
end
test "[APP] generating engine's route includes default_url_options[:script_name]" do
- RailsApplication.routes.default_url_options = {:script_name => "/something"}
+ RailsApplication.routes.default_url_options = {script_name: "/something"}
get "/generate"
assert_equal "/something/awesome/blog/posts/1", last_response.body
end
@@ -269,16 +269,16 @@ module TestGenerationPrefix
end
test "[OBJECT] generating engine's route includes prefix" do
- assert_equal "/awesome/blog/posts/1", engine_object.post_path(:id => 1)
+ assert_equal "/awesome/blog/posts/1", engine_object.post_path(id: 1)
end
test "[OBJECT] generating engine's route includes dynamic prefix" do
- assert_equal "/pure-awesomeness/blog/posts/3", engine_object.post_path(:id => 3, :omg => "pure-awesomeness")
+ assert_equal "/pure-awesomeness/blog/posts/3", engine_object.post_path(id: 3, omg: "pure-awesomeness")
end
test "[OBJECT] generating engine's route includes default_url_options[:script_name]" do
- RailsApplication.routes.default_url_options = {:script_name => "/something"}
- assert_equal "/something/pure-awesomeness/blog/posts/3", engine_object.post_path(:id => 3, :omg => "pure-awesomeness")
+ RailsApplication.routes.default_url_options = {script_name: "/something"}
+ assert_equal "/something/pure-awesomeness/blog/posts/3", engine_object.post_path(id: 3, omg: "pure-awesomeness")
end
test "[OBJECT] generating application's route" do
@@ -286,7 +286,7 @@ module TestGenerationPrefix
end
test "[OBJECT] generating application's route includes default_url_options[:script_name]" do
- RailsApplication.routes.default_url_options = {:script_name => "/something"}
+ RailsApplication.routes.default_url_options = {script_name: "/something"}
assert_equal "/something/", app_object.root_path
end
@@ -296,11 +296,11 @@ module TestGenerationPrefix
end
test "[OBJECT] generating engine's route with url_for" do
- path = engine_object.url_for(:controller => "inside_engine_generating",
- :action => "show",
- :only_path => true,
- :omg => "omg",
- :id => 1)
+ path = engine_object.url_for(controller: "inside_engine_generating",
+ action: "show",
+ only_path: true,
+ omg: "omg",
+ id: 1)
assert_equal "/omg/blog/posts/1", path
end
@@ -308,7 +308,7 @@ module TestGenerationPrefix
path = engine_object.posts_path
assert_equal "/awesome/blog/posts", path
- path = engine_object.posts_url(:host => "example.com")
+ path = engine_object.posts_url(host: "example.com")
assert_equal "http://example.com/awesome/blog/posts", path
end
@@ -316,7 +316,7 @@ module TestGenerationPrefix
path = engine_object.polymorphic_path(Post.new)
assert_equal "/awesome/blog/posts/1", path
- path = engine_object.polymorphic_url(Post.new, :host => "www.example.com")
+ path = engine_object.polymorphic_url(Post.new, host: "www.example.com")
assert_equal "http://www.example.com/awesome/blog/posts/1", path
end
@@ -340,21 +340,21 @@ module TestGenerationPrefix
@routes ||= begin
routes = ActionDispatch::Routing::RouteSet.new
routes.draw do
- get "/posts/:id", :to => "posts#show", :as => :post
-
- get "/relative_path_root", :to => redirect("")
- get "/relative_path_redirect", :to => redirect("foo")
- get "/relative_option_root", :to => redirect(:path => "")
- get "/relative_option_redirect", :to => redirect(:path => "foo")
- get "/relative_custom_root", :to => redirect { |params, request| "" }
- get "/relative_custom_redirect", :to => redirect { |params, request| "foo" }
-
- get "/absolute_path_root", :to => redirect("/")
- get "/absolute_path_redirect", :to => redirect("/foo")
- get "/absolute_option_root", :to => redirect(:path => "/")
- get "/absolute_option_redirect", :to => redirect(:path => "/foo")
- get "/absolute_custom_root", :to => redirect { |params, request| "/" }
- get "/absolute_custom_redirect", :to => redirect { |params, request| "/foo" }
+ get "/posts/:id", to: "posts#show", as: :post
+
+ get "/relative_path_root", to: redirect("")
+ get "/relative_path_redirect", to: redirect("foo")
+ get "/relative_option_root", to: redirect(path: "")
+ get "/relative_option_redirect", to: redirect(path: "foo")
+ get "/relative_custom_root", to: redirect { |params, request| "" }
+ get "/relative_custom_redirect", to: redirect { |params, request| "foo" }
+
+ get "/absolute_path_root", to: redirect("/")
+ get "/absolute_path_redirect", to: redirect("/foo")
+ get "/absolute_option_root", to: redirect(path: "/")
+ get "/absolute_option_redirect", to: redirect(path: "/foo")
+ get "/absolute_custom_root", to: redirect { |params, request| "/" }
+ get "/absolute_custom_redirect", to: redirect { |params, request| "/foo" }
end
routes
diff --git a/actionpack/test/dispatch/rack_cache_test.rb b/actionpack/test/dispatch/rack_cache_test.rb
index c3c03c7df2..e421cbdbce 100644
--- a/actionpack/test/dispatch/rack_cache_test.rb
+++ b/actionpack/test/dispatch/rack_cache_test.rb
@@ -12,7 +12,7 @@ class RackCacheMetaStoreTest < ActiveSupport::TestCase
end
test "stuff is deep duped" do
- @store.write(:foo, { :bar => :original })
+ @store.write(:foo, { bar: :original })
hash = @store.read(:foo)
hash[:bar] = :changed
hash = @store.read(:foo)
diff --git a/actionpack/test/dispatch/reloader_test.rb b/actionpack/test/dispatch/reloader_test.rb
index 0ad51af364..5dd3414958 100644
--- a/actionpack/test/dispatch/reloader_test.rb
+++ b/actionpack/test/dispatch/reloader_test.rb
@@ -166,7 +166,7 @@ class ReloaderTest < ActiveSupport::TestCase
i = 10
assert_deprecated do
Reloader.to_prepare { i += 1 }
- Reloader.to_prepare(:prepend => true) { i = 0 }
+ Reloader.to_prepare(prepend: true) { i = 0 }
end
assert_deprecated do
diff --git a/actionpack/test/dispatch/request/json_params_parsing_test.rb b/actionpack/test/dispatch/request/json_params_parsing_test.rb
index 039888b895..20e16dc0c2 100644
--- a/actionpack/test/dispatch/request/json_params_parsing_test.rb
+++ b/actionpack/test/dispatch/request/json_params_parsing_test.rb
@@ -104,7 +104,7 @@ class JsonParamsParsingTest < ActionDispatch::IntegrationTest
with_routing do |set|
set.draw do
ActiveSupport::Deprecation.silence do
- post ":action", :to => ::JsonParamsParsingTest::TestController
+ post ":action", to: ::JsonParamsParsingTest::TestController
end
end
yield
@@ -114,7 +114,7 @@ end
class RootLessJSONParamsParsingTest < ActionDispatch::IntegrationTest
class UsersController < ActionController::Base
- wrap_parameters :format => :json
+ wrap_parameters format: :json
class << self
attr_accessor :last_request_parameters, :last_parameters
@@ -194,7 +194,7 @@ class RootLessJSONParamsParsingTest < ActionDispatch::IntegrationTest
with_routing do |set|
set.draw do
ActiveSupport::Deprecation.silence do
- post ":action", :to => controller
+ post ":action", to: controller
end
end
yield
diff --git a/actionpack/test/dispatch/request/multipart_params_parsing_test.rb b/actionpack/test/dispatch/request/multipart_params_parsing_test.rb
index 67cd9ab85d..2714b7f50b 100644
--- a/actionpack/test/dispatch/request/multipart_params_parsing_test.rb
+++ b/actionpack/test/dispatch/request/multipart_params_parsing_test.rb
@@ -143,7 +143,7 @@ class MultipartParamsParsingTest < ActionDispatch::IntegrationTest
test "uploads and reads binary file" do
with_test_routing do
fixture = FIXTURE_PATH + "/mona_lisa.jpg"
- params = { :uploaded_data => fixture_file_upload(fixture, "image/jpg") }
+ params = { uploaded_data: fixture_file_upload(fixture, "image/jpg") }
post "/read", params: params
end
end
@@ -191,7 +191,7 @@ class MultipartParamsParsingTest < ActionDispatch::IntegrationTest
with_routing do |set|
set.draw do
ActiveSupport::Deprecation.silence do
- post ":action", :controller => "multipart_params_parsing_test/test"
+ post ":action", controller: "multipart_params_parsing_test/test"
end
end
yield
diff --git a/actionpack/test/dispatch/request/query_string_parsing_test.rb b/actionpack/test/dispatch/request/query_string_parsing_test.rb
index 4f8d4ccd34..6763dbf243 100644
--- a/actionpack/test/dispatch/request/query_string_parsing_test.rb
+++ b/actionpack/test/dispatch/request/query_string_parsing_test.rb
@@ -145,7 +145,7 @@ class QueryStringParsingTest < ActionDispatch::IntegrationTest
with_routing do |set|
set.draw do
ActiveSupport::Deprecation.silence do
- get ":action", :to => ::QueryStringParsingTest::TestController
+ get ":action", to: ::QueryStringParsingTest::TestController
end
end
@@ -159,7 +159,7 @@ class QueryStringParsingTest < ActionDispatch::IntegrationTest
with_routing do |set|
set.draw do
ActiveSupport::Deprecation.silence do
- get ":action", :to => ::QueryStringParsingTest::TestController
+ get ":action", to: ::QueryStringParsingTest::TestController
end
end
@app = self.class.build_app(set) do |middleware|
diff --git a/actionpack/test/dispatch/request/session_test.rb b/actionpack/test/dispatch/request/session_test.rb
index 2f0042df29..b599fe5437 100644
--- a/actionpack/test/dispatch/request/session_test.rb
+++ b/actionpack/test/dispatch/request/session_test.rb
@@ -74,7 +74,7 @@ module ActionDispatch
s = Session.create(store, req, {})
s["rails"] = "ftw"
- s.update(:rails => "awesome")
+ s.update(rails: "awesome")
assert_equal(["rails"], s.keys)
assert_equal("awesome", s["rails"])
diff --git a/actionpack/test/dispatch/request_id_test.rb b/actionpack/test/dispatch/request_id_test.rb
index 39d999aa82..d64ee7607d 100644
--- a/actionpack/test/dispatch/request_id_test.rb
+++ b/actionpack/test/dispatch/request_id_test.rb
@@ -56,7 +56,7 @@ class RequestIdResponseTest < ActionDispatch::IntegrationTest
def with_test_route_set
with_routing do |set|
set.draw do
- get "/", :to => ::RequestIdResponseTest::TestController.action(:index)
+ get "/", to: ::RequestIdResponseTest::TestController.action(:index)
end
@app = self.class.build_app(set) do |middleware|
diff --git a/actionpack/test/dispatch/request_test.rb b/actionpack/test/dispatch/request_test.rb
index ab1f10ae0d..0cac971daa 100644
--- a/actionpack/test/dispatch/request_test.rb
+++ b/actionpack/test/dispatch/request_test.rb
@@ -34,28 +34,28 @@ end
class RequestUrlFor < BaseRequestTest
test "url_for class method" do
- e = assert_raise(ArgumentError) { url_for(:host => nil) }
+ e = assert_raise(ArgumentError) { url_for(host: nil) }
assert_match(/Please provide the :host parameter/, e.message)
- assert_equal "/books", url_for(:only_path => true, :path => "/books")
+ assert_equal "/books", url_for(only_path: true, path: "/books")
assert_equal "http://www.example.com/books/?q=code", url_for(trailing_slash: true, path: "/books?q=code")
assert_equal "http://www.example.com/books/?spareslashes=////", url_for(trailing_slash: true, path: "/books?spareslashes=////")
assert_equal "http://www.example.com", url_for
- assert_equal "http://api.example.com", url_for(:subdomain => "api")
- assert_equal "http://example.com", url_for(:subdomain => false)
- assert_equal "http://www.ror.com", url_for(:domain => "ror.com")
- assert_equal "http://api.ror.co.uk", url_for(:host => "www.ror.co.uk", :subdomain => "api", :tld_length => 2)
- assert_equal "http://www.example.com:8080", url_for(:port => 8080)
- assert_equal "https://www.example.com", url_for(:protocol => "https")
- assert_equal "http://www.example.com/docs", url_for(:path => "/docs")
- assert_equal "http://www.example.com#signup", url_for(:anchor => "signup")
- assert_equal "http://www.example.com/", url_for(:trailing_slash => true)
- assert_equal "http://dhh:supersecret@www.example.com", url_for(:user => "dhh", :password => "supersecret")
- assert_equal "http://www.example.com?search=books", url_for(:params => { :search => "books" })
- assert_equal "http://www.example.com?params=", url_for(:params => "")
- assert_equal "http://www.example.com?params=1", url_for(:params => 1)
+ assert_equal "http://api.example.com", url_for(subdomain: "api")
+ assert_equal "http://example.com", url_for(subdomain: false)
+ assert_equal "http://www.ror.com", url_for(domain: "ror.com")
+ assert_equal "http://api.ror.co.uk", url_for(host: "www.ror.co.uk", subdomain: "api", tld_length: 2)
+ assert_equal "http://www.example.com:8080", url_for(port: 8080)
+ assert_equal "https://www.example.com", url_for(protocol: "https")
+ assert_equal "http://www.example.com/docs", url_for(path: "/docs")
+ assert_equal "http://www.example.com#signup", url_for(anchor: "signup")
+ assert_equal "http://www.example.com/", url_for(trailing_slash: true)
+ assert_equal "http://dhh:supersecret@www.example.com", url_for(user: "dhh", password: "supersecret")
+ assert_equal "http://www.example.com?search=books", url_for(params: { search: "books" })
+ assert_equal "http://www.example.com?params=", url_for(params: "")
+ assert_equal "http://www.example.com?params=1", url_for(params: 1)
end
end
diff --git a/actionpack/test/dispatch/response_test.rb b/actionpack/test/dispatch/response_test.rb
index 24a17ca740..1efcd9e97f 100644
--- a/actionpack/test/dispatch/response_test.rb
+++ b/actionpack/test/dispatch/response_test.rb
@@ -221,23 +221,23 @@ class ResponseTest < ActiveSupport::TestCase
end
test "cookies" do
- @response.set_cookie("user_name", :value => "david", :path => "/")
+ @response.set_cookie("user_name", value: "david", path: "/")
_status, headers, _body = @response.to_a
assert_equal "user_name=david; path=/", headers["Set-Cookie"]
assert_equal({"user_name" => "david"}, @response.cookies)
end
test "multiple cookies" do
- @response.set_cookie("user_name", :value => "david", :path => "/")
- @response.set_cookie("login", :value => "foo&bar", :path => "/", :expires => Time.utc(2005, 10, 10,5))
+ @response.set_cookie("user_name", value: "david", path: "/")
+ @response.set_cookie("login", value: "foo&bar", path: "/", expires: Time.utc(2005, 10, 10,5))
_status, headers, _body = @response.to_a
assert_equal "user_name=david; path=/\nlogin=foo%26bar; path=/; expires=Mon, 10 Oct 2005 05:00:00 -0000", headers["Set-Cookie"]
assert_equal({"login" => "foo&bar", "user_name" => "david"}, @response.cookies)
end
test "delete cookies" do
- @response.set_cookie("user_name", :value => "david", :path => "/")
- @response.set_cookie("login", :value => "foo&bar", :path => "/", :expires => Time.utc(2005, 10, 10,5))
+ @response.set_cookie("user_name", value: "david", path: "/")
+ @response.set_cookie("login", value: "foo&bar", path: "/", expires: Time.utc(2005, 10, 10,5))
@response.delete_cookie("login")
assert_equal({"user_name" => "david", "login" => nil}, @response.cookies)
end
@@ -254,7 +254,7 @@ class ResponseTest < ActiveSupport::TestCase
assert resp.weak_etag?
assert_not resp.strong_etag?
assert_equal('W/"202cb962ac59075b964b07152d234b70"', resp.etag)
- assert_equal({:public => true}, resp.cache_control)
+ assert_equal({public: true}, resp.cache_control)
assert_equal("public", resp.headers["Cache-Control"])
assert_equal('W/"202cb962ac59075b964b07152d234b70"', resp.headers["ETag"])
@@ -461,7 +461,7 @@ class ResponseIntegrationTest < ActionDispatch::IntegrationTest
assert_equal('W/"202cb962ac59075b964b07152d234b70"', @response.headers["ETag"])
assert_equal('W/"202cb962ac59075b964b07152d234b70"', @response.etag)
- assert_equal({:public => true}, @response.cache_control)
+ assert_equal({public: true}, @response.cache_control)
end
test "response cache control from rackish app" do
@@ -478,7 +478,7 @@ class ResponseIntegrationTest < ActionDispatch::IntegrationTest
assert_equal('W/"202cb962ac59075b964b07152d234b70"', @response.headers["ETag"])
assert_equal('W/"202cb962ac59075b964b07152d234b70"', @response.etag)
- assert_equal({:public => true}, @response.cache_control)
+ assert_equal({public: true}, @response.cache_control)
end
test "response charset and content type from railsish app" do
diff --git a/actionpack/test/dispatch/routing/inspector_test.rb b/actionpack/test/dispatch/routing/inspector_test.rb
index 4686b53cab..07d0a8aefd 100644
--- a/actionpack/test/dispatch/routing/inspector_test.rb
+++ b/actionpack/test/dispatch/routing/inspector_test.rb
@@ -30,11 +30,11 @@ module ActionDispatch
end
end
engine.routes.draw do
- get "/cart", :to => "cart#show"
+ get "/cart", to: "cart#show"
end
output = draw do
- get "/custom/assets", :to => "custom_assets#show"
+ get "/custom/assets", to: "custom_assets#show"
mount engine => "/blog", :as => "blog"
end
@@ -71,7 +71,7 @@ module ActionDispatch
def test_cart_inspect
output = draw do
- get "/cart", :to => "cart#show"
+ get "/cart", to: "cart#show"
end
assert_equal [
@@ -93,7 +93,7 @@ module ActionDispatch
def test_inspect_shows_custom_assets
output = draw do
- get "/custom/assets", :to => "custom_assets#show"
+ get "/custom/assets", to: "custom_assets#show"
end
assert_equal [
@@ -122,7 +122,7 @@ module ActionDispatch
def test_inspect_routes_shows_root_route
output = draw do
- root :to => "pages#main"
+ root to: "pages#main"
end
assert_equal [
@@ -160,7 +160,7 @@ module ActionDispatch
def test_inspect_routes_shows_controller_and_action_route_with_constraints
output = draw do
ActiveSupport::Deprecation.silence do
- get ":controller(/:action(/:id))", :id => /\d+/
+ get ":controller(/:action(/:id))", id: /\d+/
end
end
@@ -172,7 +172,7 @@ module ActionDispatch
def test_rails_routes_shows_route_with_defaults
output = draw do
- get "photos/:id" => "photos#show", :defaults => {:format => "jpg"}
+ get "photos/:id" => "photos#show", :defaults => {format: "jpg"}
end
assert_equal [
@@ -256,7 +256,7 @@ module ActionDispatch
end
output = draw do
- scope :constraint => constraint.new do
+ scope constraint: constraint.new do
mount MountedRackApp => "/foo"
end
end
@@ -289,7 +289,7 @@ module ActionDispatch
def test_redirect
output = draw do
- get "/foo" => redirect("/foo/bar"), :constraints => { :subdomain => "admin" }
+ get "/foo" => redirect("/foo/bar"), :constraints => { subdomain: "admin" }
get "/bar" => redirect(path: "/foo/bar", status: 307)
get "/foobar" => redirect{ "/foo/bar" }
end
diff --git a/actionpack/test/dispatch/routing/ipv6_redirect_test.rb b/actionpack/test/dispatch/routing/ipv6_redirect_test.rb
index 866b492bad..b227aca658 100644
--- a/actionpack/test/dispatch/routing/ipv6_redirect_test.rb
+++ b/actionpack/test/dispatch/routing/ipv6_redirect_test.rb
@@ -7,17 +7,17 @@ class IPv6IntegrationTest < ActionDispatch::IntegrationTest
class ::BadRouteRequestController < ActionController::Base
include Routes.url_helpers
def index
- render :text => foo_path
+ render text: foo_path
end
def foo
- redirect_to :action => :index
+ redirect_to action: :index
end
end
Routes.draw do
- get "/", :to => "bad_route_request#index", :as => :index
- get "/foo", :to => "bad_route_request#foo", :as => :foo
+ get "/", to: "bad_route_request#index", as: :index
+ get "/foo", to: "bad_route_request#foo", as: :foo
end
def _routes
diff --git a/actionpack/test/dispatch/routing_assertions_test.rb b/actionpack/test/dispatch/routing_assertions_test.rb
index 640d339c34..1e77c7311e 100644
--- a/actionpack/test/dispatch/routing_assertions_test.rb
+++ b/actionpack/test/dispatch/routing_assertions_test.rb
@@ -12,119 +12,119 @@ class RoutingAssertionsTest < ActionController::TestCase
@routes.draw do
resources :articles
- scope "secure", :constraints => { :protocol => "https://" } do
- resources :articles, :controller => "secure_articles"
+ scope "secure", constraints: { protocol: "https://" } do
+ resources :articles, controller: "secure_articles"
end
- scope "block", :constraints => lambda { |r| r.ssl? } do
- resources :articles, :controller => "block_articles"
+ scope "block", constraints: lambda { |r| r.ssl? } do
+ resources :articles, controller: "block_articles"
end
- scope "query", :constraints => lambda { |r| r.params[:use_query] == "true" } do
- resources :articles, :controller => "query_articles"
+ scope "query", constraints: lambda { |r| r.params[:use_query] == "true" } do
+ resources :articles, controller: "query_articles"
end
end
end
def test_assert_generates
- assert_generates("/articles", { :controller => "articles", :action => "index" })
- assert_generates("/articles/1", { :controller => "articles", :action => "show", :id => "1" })
+ assert_generates("/articles", { controller: "articles", action: "index" })
+ assert_generates("/articles/1", { controller: "articles", action: "show", id: "1" })
end
def test_assert_generates_with_defaults
- assert_generates("/articles/1/edit", { :controller => "articles", :action => "edit" }, { :id => "1" })
+ assert_generates("/articles/1/edit", { controller: "articles", action: "edit" }, { id: "1" })
end
def test_assert_generates_with_extras
- assert_generates("/articles", { :controller => "articles", :action => "index", :page => "1" }, {}, { :page => "1" })
+ assert_generates("/articles", { controller: "articles", action: "index", page: "1" }, {}, { page: "1" })
end
def test_assert_recognizes
- assert_recognizes({ :controller => "articles", :action => "index" }, "/articles")
- assert_recognizes({ :controller => "articles", :action => "show", :id => "1" }, "/articles/1")
+ assert_recognizes({ controller: "articles", action: "index" }, "/articles")
+ assert_recognizes({ controller: "articles", action: "show", id: "1" }, "/articles/1")
end
def test_assert_recognizes_with_extras
- assert_recognizes({ :controller => "articles", :action => "index", :page => "1" }, "/articles", { :page => "1" })
+ assert_recognizes({ controller: "articles", action: "index", page: "1" }, "/articles", { page: "1" })
end
def test_assert_recognizes_with_method
- assert_recognizes({ :controller => "articles", :action => "create" }, { :path => "/articles", :method => :post })
- assert_recognizes({ :controller => "articles", :action => "update", :id => "1" }, { :path => "/articles/1", :method => :put })
+ assert_recognizes({ controller: "articles", action: "create" }, { path: "/articles", method: :post })
+ assert_recognizes({ controller: "articles", action: "update", id: "1" }, { path: "/articles/1", method: :put })
end
def test_assert_recognizes_with_hash_constraint
assert_raise(Assertion) do
- assert_recognizes({ :controller => "secure_articles", :action => "index" }, "http://test.host/secure/articles")
+ assert_recognizes({ controller: "secure_articles", action: "index" }, "http://test.host/secure/articles")
end
- assert_recognizes({ :controller => "secure_articles", :action => "index", :protocol => "https://" }, "https://test.host/secure/articles")
+ assert_recognizes({ controller: "secure_articles", action: "index", protocol: "https://" }, "https://test.host/secure/articles")
end
def test_assert_recognizes_with_block_constraint
assert_raise(Assertion) do
- assert_recognizes({ :controller => "block_articles", :action => "index" }, "http://test.host/block/articles")
+ assert_recognizes({ controller: "block_articles", action: "index" }, "http://test.host/block/articles")
end
- assert_recognizes({ :controller => "block_articles", :action => "index" }, "https://test.host/block/articles")
+ assert_recognizes({ controller: "block_articles", action: "index" }, "https://test.host/block/articles")
end
def test_assert_recognizes_with_query_constraint
assert_raise(Assertion) do
- assert_recognizes({ :controller => "query_articles", :action => "index", :use_query => "false" }, "/query/articles", { :use_query => "false" })
+ assert_recognizes({ controller: "query_articles", action: "index", use_query: "false" }, "/query/articles", { use_query: "false" })
end
- assert_recognizes({ :controller => "query_articles", :action => "index", :use_query => "true" }, "/query/articles", { :use_query => "true" })
+ assert_recognizes({ controller: "query_articles", action: "index", use_query: "true" }, "/query/articles", { use_query: "true" })
end
def test_assert_recognizes_raises_message
err = assert_raise(Assertion) do
- assert_recognizes({ :controller => "secure_articles", :action => "index" }, "http://test.host/secure/articles", {}, "This is a really bad msg")
+ assert_recognizes({ controller: "secure_articles", action: "index" }, "http://test.host/secure/articles", {}, "This is a really bad msg")
end
assert_match err.message, "This is a really bad msg"
end
def test_assert_routing
- assert_routing("/articles", :controller => "articles", :action => "index")
+ assert_routing("/articles", controller: "articles", action: "index")
end
def test_assert_routing_raises_message
err = assert_raise(Assertion) do
- assert_routing("/thisIsNotARoute", { :controller => "articles", :action => "edit", :id => "1" }, { :id => "1" }, {}, "This is a really bad msg")
+ assert_routing("/thisIsNotARoute", { controller: "articles", action: "edit", id: "1" }, { id: "1" }, {}, "This is a really bad msg")
end
assert_match err.message, "This is a really bad msg"
end
def test_assert_routing_with_defaults
- assert_routing("/articles/1/edit", { :controller => "articles", :action => "edit", :id => "1" }, { :id => "1" })
+ assert_routing("/articles/1/edit", { controller: "articles", action: "edit", id: "1" }, { id: "1" })
end
def test_assert_routing_with_extras
- assert_routing("/articles", { :controller => "articles", :action => "index", :page => "1" }, { }, { :page => "1" })
+ assert_routing("/articles", { controller: "articles", action: "index", page: "1" }, { }, { page: "1" })
end
def test_assert_routing_with_hash_constraint
assert_raise(Assertion) do
- assert_routing("http://test.host/secure/articles", { :controller => "secure_articles", :action => "index" })
+ assert_routing("http://test.host/secure/articles", { controller: "secure_articles", action: "index" })
end
- assert_routing("https://test.host/secure/articles", { :controller => "secure_articles", :action => "index", :protocol => "https://" })
+ assert_routing("https://test.host/secure/articles", { controller: "secure_articles", action: "index", protocol: "https://" })
end
def test_assert_routing_with_block_constraint
assert_raise(Assertion) do
- assert_routing("http://test.host/block/articles", { :controller => "block_articles", :action => "index" })
+ assert_routing("http://test.host/block/articles", { controller: "block_articles", action: "index" })
end
- assert_routing("https://test.host/block/articles", { :controller => "block_articles", :action => "index" })
+ assert_routing("https://test.host/block/articles", { controller: "block_articles", action: "index" })
end
def test_with_routing
with_routing do |routes|
routes.draw do
- resources :articles, :path => "artikel"
+ resources :articles, path: "artikel"
end
- assert_routing("/artikel", :controller => "articles", :action => "index")
+ assert_routing("/artikel", controller: "articles", action: "index")
assert_raise(Assertion) do
- assert_routing("/articles", { :controller => "articles", :action => "index" })
+ assert_routing("/articles", { controller: "articles", action: "index" })
end
end
end
diff --git a/actionpack/test/dispatch/routing_test.rb b/actionpack/test/dispatch/routing_test.rb
index 362bce8351..6994c7e897 100644
--- a/actionpack/test/dispatch/routing_test.rb
+++ b/actionpack/test/dispatch/routing_test.rb
@@ -36,12 +36,12 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
assert_equal "sessions#destroy", @response.body
assert_equal "/logout", logout_path
- assert_equal "/logout", url_for(:controller => "sessions", :action => "destroy", :only_path => true)
+ assert_equal "/logout", url_for(controller: "sessions", action: "destroy", only_path: true)
end
def test_login
draw do
- default_url_options :host => "rubyonrails.org"
+ default_url_options host: "rubyonrails.org"
controller :sessions do
get "login" => :new
@@ -56,16 +56,16 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
post "/login"
assert_equal "sessions#create", @response.body
- assert_equal "/login", url_for(:controller => "sessions", :action => "create", :only_path => true)
- assert_equal "/login", url_for(:controller => "sessions", :action => "new", :only_path => true)
+ assert_equal "/login", url_for(controller: "sessions", action: "create", only_path: true)
+ assert_equal "/login", url_for(controller: "sessions", action: "new", only_path: true)
- assert_equal "http://rubyonrails.org/login", url_for(:controller => "sessions", :action => "create")
+ assert_equal "http://rubyonrails.org/login", url_for(controller: "sessions", action: "create")
assert_equal "http://rubyonrails.org/login", login_url
end
def test_login_redirect
draw do
- get "account/login", :to => redirect("/login")
+ get "account/login", to: redirect("/login")
end
get "/account/login"
@@ -85,8 +85,8 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
def test_namespace_redirect
draw do
namespace :private do
- root :to => redirect("/private/index")
- get "index", :to => "private#index"
+ root to: redirect("/private/index")
+ get "index", to: "private#index"
end
end
@@ -236,7 +236,7 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
def test_redirect_modulo
draw do
- get "account/modulo/:name", :to => redirect("/%{name}s")
+ get "account/modulo/:name", to: redirect("/%{name}s")
end
get "/account/modulo/name"
@@ -245,7 +245,7 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
def test_redirect_proc
draw do
- get "account/proc/:name", :to => redirect {|params, req| "/#{params[:name].pluralize}" }
+ get "account/proc/:name", to: redirect {|params, req| "/#{params[:name].pluralize}" }
end
get "/account/proc/person"
@@ -263,7 +263,7 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
def test_redirect_hash_with_subdomain
draw do
- get "mobile", :to => redirect(:subdomain => "mobile")
+ get "mobile", to: redirect(subdomain: "mobile")
end
get "/mobile"
@@ -272,7 +272,7 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
def test_redirect_hash_with_domain_and_path
draw do
- get "documentation", :to => redirect(:domain => "example-documentation.com", :path => "")
+ get "documentation", to: redirect(domain: "example-documentation.com", path: "")
end
get "/documentation"
@@ -281,7 +281,7 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
def test_redirect_hash_with_path
draw do
- get "new_documentation", :to => redirect(:path => "/documentation/new")
+ get "new_documentation", to: redirect(path: "/documentation/new")
end
get "/new_documentation"
@@ -290,7 +290,7 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
def test_redirect_hash_with_host
draw do
- get "super_new_documentation", :to => redirect(:host => "super-docs.com")
+ get "super_new_documentation", to: redirect(host: "super-docs.com")
end
get "/super_new_documentation?section=top"
@@ -299,7 +299,7 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
def test_redirect_hash_path_substitution
draw do
- get "stores/:name", :to => redirect(:subdomain => "stores", :path => "/%{name}")
+ get "stores/:name", to: redirect(subdomain: "stores", path: "/%{name}")
end
get "/stores/iernest"
@@ -308,7 +308,7 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
def test_redirect_hash_path_substitution_with_catch_all
draw do
- get "stores/:name(*rest)", :to => redirect(:subdomain => "stores", :path => "/%{name}%{rest}")
+ get "stores/:name(*rest)", to: redirect(subdomain: "stores", path: "/%{name}%{rest}")
end
get "/stores/iernest/products"
@@ -317,7 +317,7 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
def test_redirect_class
draw do
- get "youtube_favorites/:youtube_id/:name", :to => redirect(YoutubeFavoritesRedirector)
+ get "youtube_favorites/:youtube_id/:name", to: redirect(YoutubeFavoritesRedirector)
end
get "/youtube_favorites/oHg5SJYRHA0/rick-rolld"
@@ -326,7 +326,7 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
def test_openid
draw do
- match "openid/login", :via => [:get, :post], :to => "openid#login"
+ match "openid/login", via: [:get, :post], to: "openid#login"
end
get "/openid/login"
@@ -338,11 +338,11 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
def test_bookmarks
draw do
- scope "bookmark", :controller => "bookmarks", :as => :bookmark do
- get :new, :path => "build"
- post :create, :path => "create", :as => ""
+ scope "bookmark", controller: "bookmarks", as: :bookmark do
+ get :new, path: "build"
+ post :create, path: "create", as: ""
put :update
- get :remove, :action => :destroy, :as => :remove
+ get :remove, action: :destroy, as: :remove
end
end
@@ -366,13 +366,13 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
def test_pagemarks
tc = self
draw do
- scope "pagemark", :controller => "pagemarks", :as => :pagemark do
+ scope "pagemark", controller: "pagemarks", as: :pagemark do
tc.assert_deprecated do
- get "new", :path => "build"
+ get "new", path: "build"
end
- post "create", :as => ""
+ post "create", as: ""
put "update"
- get "remove", :action => :destroy, :as => :remove
+ get "remove", action: :destroy, as: :remove
tc.assert_deprecated do
get action: :show, as: :show
end
@@ -402,7 +402,7 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
def test_admin
draw do
- constraints(:ip => /192\.168\.1\.\d\d\d/) do
+ constraints(ip: /192\.168\.1\.\d\d\d/) do
get "admin" => "queenbee#index"
end
@@ -436,8 +436,8 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
draw do
controller(:global) do
get "global/hide_notice"
- get "global/export", :action => :export, :as => :export_request
- get "/export/:id/:file", :action => :export, :as => :export_download, :constraints => { :file => /.*/ }
+ get "global/export", action: :export, as: :export_request
+ get "/export/:id/:file", action: :export, as: :export_download, constraints: { file: /.*/ }
ActiveSupport::Deprecation.silence do
get "global/:action"
@@ -459,13 +459,13 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
assert_equal "/global/export", export_request_path
assert_equal "/global/hide_notice", global_hide_notice_path
- assert_equal "/export/123/foo.txt", export_download_path(:id => 123, :file => "foo.txt")
+ assert_equal "/export/123/foo.txt", export_download_path(id: 123, file: "foo.txt")
end
def test_local
draw do
ActiveSupport::Deprecation.silence do
- get "/local/:action", :controller => "local"
+ get "/local/:action", controller: "local"
end
end
@@ -480,7 +480,7 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
end
# without dup, additional (and possibly unwanted) values will be present in the options (eg. :host)
- original_options = {:controller => "projects", :action => "status"}
+ original_options = {controller: "projects", action: "status"}
options = original_options.dup
url_for options
@@ -495,7 +495,7 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
end
controller = "/projects"
- options = {:controller => controller, :action => "status", :only_path => true}
+ options = {controller: controller, action: "status", only_path: true}
url = url_for(options)
assert_equal "/projects/status", url
@@ -506,11 +506,11 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
def test_named_route_with_no_side_effects
draw do
resources :customers do
- get "profile", :on => :member
+ get "profile", on: :member
end
end
- original_options = { :host => "test.host" }
+ original_options = { host: "test.host" }
options = original_options.dup
profile_customer_url("customer_model", options)
@@ -524,13 +524,13 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
get "/projects/status(.:format)"
end
- assert_equal "/projects/status", url_for(:controller => "projects", :action => "status", :only_path => true)
- assert_equal "/projects/status.json", url_for(:controller => "projects", :action => "status", :format => "json", :only_path => true)
+ assert_equal "/projects/status", url_for(controller: "projects", action: "status", only_path: true)
+ assert_equal "/projects/status.json", url_for(controller: "projects", action: "status", format: "json", only_path: true)
end
def test_projects
draw do
- resources :projects, :controller => :project
+ resources :projects, controller: :project
end
get "/projects"
@@ -542,7 +542,7 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
get "/projects.xml"
assert_equal "project#index", @response.body
- assert_equal "/projects.xml", projects_path(:format => "xml")
+ assert_equal "/projects.xml", projects_path(format: "xml")
get "/projects/new"
assert_equal "project#new", @response.body
@@ -550,19 +550,19 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
get "/projects/new.xml"
assert_equal "project#new", @response.body
- assert_equal "/projects/new.xml", new_project_path(:format => "xml")
+ assert_equal "/projects/new.xml", new_project_path(format: "xml")
get "/projects/1"
assert_equal "project#show", @response.body
- assert_equal "/projects/1", project_path(:id => "1")
+ assert_equal "/projects/1", project_path(id: "1")
get "/projects/1.xml"
assert_equal "project#show", @response.body
- assert_equal "/projects/1.xml", project_path(:id => "1", :format => "xml")
+ assert_equal "/projects/1.xml", project_path(id: "1", format: "xml")
get "/projects/1/edit"
assert_equal "project#edit", @response.body
- assert_equal "/projects/1/edit", edit_project_path(:id => "1")
+ assert_equal "/projects/1/edit", edit_project_path(id: "1")
end
def test_projects_for_api_app
@@ -601,8 +601,8 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
def test_projects_with_post_action_and_new_path_on_collection
draw do
- resources :projects, :controller => :project do
- post "new", :action => "new", :on => :collection, :as => :new
+ resources :projects, controller: :project do
+ post "new", action: "new", on: :collection, as: :new
end
end
@@ -613,22 +613,22 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
def test_projects_involvements
draw do
- resources :projects, :controller => :project do
+ resources :projects, controller: :project do
resources :involvements, :attachments
end
end
get "/projects/1/involvements"
assert_equal "involvements#index", @response.body
- assert_equal "/projects/1/involvements", project_involvements_path(:project_id => "1")
+ assert_equal "/projects/1/involvements", project_involvements_path(project_id: "1")
get "/projects/1/involvements/new"
assert_equal "involvements#new", @response.body
- assert_equal "/projects/1/involvements/new", new_project_involvement_path(:project_id => "1")
+ assert_equal "/projects/1/involvements/new", new_project_involvement_path(project_id: "1")
get "/projects/1/involvements/1"
assert_equal "involvements#show", @response.body
- assert_equal "/projects/1/involvements/1", project_involvement_path(:project_id => "1", :id => "1")
+ assert_equal "/projects/1/involvements/1", project_involvement_path(project_id: "1", id: "1")
put "/projects/1/involvements/1"
assert_equal "involvements#update", @response.body
@@ -638,66 +638,66 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
get "/projects/1/involvements/1/edit"
assert_equal "involvements#edit", @response.body
- assert_equal "/projects/1/involvements/1/edit", edit_project_involvement_path(:project_id => "1", :id => "1")
+ assert_equal "/projects/1/involvements/1/edit", edit_project_involvement_path(project_id: "1", id: "1")
end
def test_projects_attachments
draw do
- resources :projects, :controller => :project do
+ resources :projects, controller: :project do
resources :involvements, :attachments
end
end
get "/projects/1/attachments"
assert_equal "attachments#index", @response.body
- assert_equal "/projects/1/attachments", project_attachments_path(:project_id => "1")
+ assert_equal "/projects/1/attachments", project_attachments_path(project_id: "1")
end
def test_projects_participants
draw do
- resources :projects, :controller => :project do
+ resources :projects, controller: :project do
resources :participants do
- put :update_all, :on => :collection
+ put :update_all, on: :collection
end
end
end
get "/projects/1/participants"
assert_equal "participants#index", @response.body
- assert_equal "/projects/1/participants", project_participants_path(:project_id => "1")
+ assert_equal "/projects/1/participants", project_participants_path(project_id: "1")
put "/projects/1/participants/update_all"
assert_equal "participants#update_all", @response.body
- assert_equal "/projects/1/participants/update_all", update_all_project_participants_path(:project_id => "1")
+ assert_equal "/projects/1/participants/update_all", update_all_project_participants_path(project_id: "1")
end
def test_projects_companies
draw do
- resources :projects, :controller => :project do
+ resources :projects, controller: :project do
resources :companies do
resources :people
- resource :avatar, :controller => :avatar
+ resource :avatar, controller: :avatar
end
end
end
get "/projects/1/companies"
assert_equal "companies#index", @response.body
- assert_equal "/projects/1/companies", project_companies_path(:project_id => "1")
+ assert_equal "/projects/1/companies", project_companies_path(project_id: "1")
get "/projects/1/companies/1/people"
assert_equal "people#index", @response.body
- assert_equal "/projects/1/companies/1/people", project_company_people_path(:project_id => "1", :company_id => "1")
+ assert_equal "/projects/1/companies/1/people", project_company_people_path(project_id: "1", company_id: "1")
get "/projects/1/companies/1/avatar"
assert_equal "avatar#show", @response.body
- assert_equal "/projects/1/companies/1/avatar", project_company_avatar_path(:project_id => "1", :company_id => "1")
+ assert_equal "/projects/1/companies/1/avatar", project_company_avatar_path(project_id: "1", company_id: "1")
end
def test_project_manager
draw do
resources :projects do
- resource :manager, :as => :super_manager do
+ resource :manager, as: :super_manager do
post :fire
end
end
@@ -705,37 +705,37 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
get "/projects/1/manager"
assert_equal "managers#show", @response.body
- assert_equal "/projects/1/manager", project_super_manager_path(:project_id => "1")
+ assert_equal "/projects/1/manager", project_super_manager_path(project_id: "1")
get "/projects/1/manager/new"
assert_equal "managers#new", @response.body
- assert_equal "/projects/1/manager/new", new_project_super_manager_path(:project_id => "1")
+ assert_equal "/projects/1/manager/new", new_project_super_manager_path(project_id: "1")
post "/projects/1/manager/fire"
assert_equal "managers#fire", @response.body
- assert_equal "/projects/1/manager/fire", fire_project_super_manager_path(:project_id => "1")
+ assert_equal "/projects/1/manager/fire", fire_project_super_manager_path(project_id: "1")
end
def test_project_images
draw do
resources :projects do
- resources :images, :as => :funny_images do
- post :revise, :on => :member
+ resources :images, as: :funny_images do
+ post :revise, on: :member
end
end
end
get "/projects/1/images"
assert_equal "images#index", @response.body
- assert_equal "/projects/1/images", project_funny_images_path(:project_id => "1")
+ assert_equal "/projects/1/images", project_funny_images_path(project_id: "1")
get "/projects/1/images/new"
assert_equal "images#new", @response.body
- assert_equal "/projects/1/images/new", new_project_funny_image_path(:project_id => "1")
+ assert_equal "/projects/1/images/new", new_project_funny_image_path(project_id: "1")
post "/projects/1/images/1/revise"
assert_equal "images#revise", @response.body
- assert_equal "/projects/1/images/1/revise", revise_project_funny_image_path(:project_id => "1", :id => "1")
+ assert_equal "/projects/1/images/1/revise", revise_project_funny_image_path(project_id: "1", id: "1")
end
def test_projects_people
@@ -758,35 +758,35 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
get "/projects/1/people"
assert_equal "people#index", @response.body
- assert_equal "/projects/1/people", project_people_path(:project_id => "1")
+ assert_equal "/projects/1/people", project_people_path(project_id: "1")
get "/projects/1/people/1"
assert_equal "people#show", @response.body
- assert_equal "/projects/1/people/1", project_person_path(:project_id => "1", :id => "1")
+ assert_equal "/projects/1/people/1", project_person_path(project_id: "1", id: "1")
get "/projects/1/people/1/7a2dec8/avatar"
assert_equal "avatars#show", @response.body
- assert_equal "/projects/1/people/1/7a2dec8/avatar", project_person_avatar_path(:project_id => "1", :person_id => "1", :access_token => "7a2dec8")
+ assert_equal "/projects/1/people/1/7a2dec8/avatar", project_person_avatar_path(project_id: "1", person_id: "1", access_token: "7a2dec8")
put "/projects/1/people/1/accessible_projects"
assert_equal "people#accessible_projects", @response.body
- assert_equal "/projects/1/people/1/accessible_projects", accessible_projects_project_person_path(:project_id => "1", :id => "1")
+ assert_equal "/projects/1/people/1/accessible_projects", accessible_projects_project_person_path(project_id: "1", id: "1")
post "/projects/1/people/1/resend"
assert_equal "people#resend", @response.body
- assert_equal "/projects/1/people/1/resend", resend_project_person_path(:project_id => "1", :id => "1")
+ assert_equal "/projects/1/people/1/resend", resend_project_person_path(project_id: "1", id: "1")
post "/projects/1/people/1/generate_new_password"
assert_equal "people#generate_new_password", @response.body
- assert_equal "/projects/1/people/1/generate_new_password", generate_new_password_project_person_path(:project_id => "1", :id => "1")
+ assert_equal "/projects/1/people/1/generate_new_password", generate_new_password_project_person_path(project_id: "1", id: "1")
end
def test_projects_with_resources_path_names
draw do
- resources_path_names :correlation_indexes => "info_about_correlation_indexes"
+ resources_path_names correlation_indexes: "info_about_correlation_indexes"
resources :projects do
- get :correlation_indexes, :on => :collection
+ get :correlation_indexes, on: :collection
end
end
@@ -799,13 +799,13 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
draw do
resources :projects do
resources :posts do
- get :archive, :toggle_view, :on => :collection
- post :preview, :on => :member
+ get :archive, :toggle_view, on: :collection
+ post :preview, on: :member
resource :subscription
resources :comments do
- post :preview, :on => :collection
+ post :preview, on: :collection
end
end
end
@@ -813,39 +813,39 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
get "/projects/1/posts"
assert_equal "posts#index", @response.body
- assert_equal "/projects/1/posts", project_posts_path(:project_id => "1")
+ assert_equal "/projects/1/posts", project_posts_path(project_id: "1")
get "/projects/1/posts/archive"
assert_equal "posts#archive", @response.body
- assert_equal "/projects/1/posts/archive", archive_project_posts_path(:project_id => "1")
+ assert_equal "/projects/1/posts/archive", archive_project_posts_path(project_id: "1")
get "/projects/1/posts/toggle_view"
assert_equal "posts#toggle_view", @response.body
- assert_equal "/projects/1/posts/toggle_view", toggle_view_project_posts_path(:project_id => "1")
+ assert_equal "/projects/1/posts/toggle_view", toggle_view_project_posts_path(project_id: "1")
post "/projects/1/posts/1/preview"
assert_equal "posts#preview", @response.body
- assert_equal "/projects/1/posts/1/preview", preview_project_post_path(:project_id => "1", :id => "1")
+ assert_equal "/projects/1/posts/1/preview", preview_project_post_path(project_id: "1", id: "1")
get "/projects/1/posts/1/subscription"
assert_equal "subscriptions#show", @response.body
- assert_equal "/projects/1/posts/1/subscription", project_post_subscription_path(:project_id => "1", :post_id => "1")
+ assert_equal "/projects/1/posts/1/subscription", project_post_subscription_path(project_id: "1", post_id: "1")
get "/projects/1/posts/1/comments"
assert_equal "comments#index", @response.body
- assert_equal "/projects/1/posts/1/comments", project_post_comments_path(:project_id => "1", :post_id => "1")
+ assert_equal "/projects/1/posts/1/comments", project_post_comments_path(project_id: "1", post_id: "1")
post "/projects/1/posts/1/comments/preview"
assert_equal "comments#preview", @response.body
- assert_equal "/projects/1/posts/1/comments/preview", preview_project_post_comments_path(:project_id => "1", :post_id => "1")
+ assert_equal "/projects/1/posts/1/comments/preview", preview_project_post_comments_path(project_id: "1", post_id: "1")
end
def test_replies
draw do
resources :replies do
member do
- put :answer, :action => :mark_as_answer
- delete :answer, :action => :unmark_as_answer
+ put :answer, action: :mark_as_answer
+ delete :answer, action: :unmark_as_answer
end
end
end
@@ -859,8 +859,8 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
def test_resource_routes_with_only_and_except
draw do
- resources :posts, :only => [:index, :show] do
- resources :comments, :except => :destroy
+ resources :posts, only: [:index, :show] do
+ resources :comments, except: :destroy
end
end
@@ -870,11 +870,11 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
get "/posts/1"
assert_equal "posts#show", @response.body
- assert_equal "/posts/1", post_path(:id => 1)
+ assert_equal "/posts/1", post_path(id: 1)
get "/posts/1/comments"
assert_equal "comments#index", @response.body
- assert_equal "/posts/1/comments", post_comments_path(:post_id => 1)
+ assert_equal "/posts/1/comments", post_comments_path(post_id: 1)
post "/posts"
assert_equal "pass", @response.headers["X-Cascade"]
@@ -888,9 +888,9 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
def test_resource_routes_only_create_update_destroy
draw do
- resource :past, :only => :destroy
- resource :present, :only => :update
- resource :future, :only => :create
+ resource :past, only: :destroy
+ resource :present, only: :update
+ resource :future, only: :create
end
delete "/past"
@@ -912,8 +912,8 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
def test_resources_routes_only_create_update_destroy
draw do
- resources :relationships, :only => [:create, :destroy]
- resources :friendships, :only => [:update]
+ resources :relationships, only: [:create, :destroy]
+ resources :friendships, only: [:update]
end
post "/relationships"
@@ -940,13 +940,13 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
get "/posts/rails-rocks"
assert_equal "posts#show", @response.body
- assert_equal "/posts/rails-rocks", post_path(:id => "rails-rocks")
+ assert_equal "/posts/rails-rocks", post_path(id: "rails-rocks")
end
def test_resources_for_uncountable_names
draw do
resources :sheep do
- get "_it", :on => :member
+ get "_it", on: :member
end
end
@@ -958,23 +958,23 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
end
def test_resource_does_not_modify_passed_options
- options = {:id => /.+?/, :format => /json|xml/}
+ options = {id: /.+?/, format: /json|xml/}
draw { resource :user, options }
- assert_equal({:id => /.+?/, :format => /json|xml/}, options)
+ assert_equal({id: /.+?/, format: /json|xml/}, options)
end
def test_resources_does_not_modify_passed_options
- options = {:id => /.+?/, :format => /json|xml/}
+ options = {id: /.+?/, format: /json|xml/}
draw { resources :users, options }
- assert_equal({:id => /.+?/, :format => /json|xml/}, options)
+ assert_equal({id: /.+?/, format: /json|xml/}, options)
end
def test_path_names
draw do
- scope "pt", :as => "pt" do
- resources :projects, :path_names => { :edit => "editar", :new => "novo" }, :path => "projetos"
- resource :admin, :path_names => { :new => "novo", :activate => "ativar" }, :path => "administrador" do
- put :activate, :on => :member
+ scope "pt", as: "pt" do
+ resources :projects, path_names: { edit: "editar", new: "novo" }, path: "projetos"
+ resource :admin, path_names: { new: "novo", activate: "ativar" }, path: "administrador" do
+ put :activate, on: :member
end
end
end
@@ -1002,10 +1002,10 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
def test_path_option_override
draw do
- scope "pt", :as => "pt" do
- resources :projects, :path_names => { :new => "novo" }, :path => "projetos" do
- put :close, :on => :member, :path => "fechar"
- get :open, :on => :new, :path => "abrir"
+ scope "pt", as: "pt" do
+ resources :projects, path_names: { new: "novo" }, path: "projetos" do
+ put :close, on: :member, path: "fechar"
+ get :open, on: :new, path: "abrir"
end
end
end
@@ -1030,30 +1030,30 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
def test_update_person_route
draw do
- get "people/:id/update", :to => "people#update", :as => :update_person
+ get "people/:id/update", to: "people#update", as: :update_person
end
get "/people/1/update"
assert_equal "people#update", @response.body
- assert_equal "/people/1/update", update_person_path(:id => 1)
+ assert_equal "/people/1/update", update_person_path(id: 1)
end
def test_update_project_person
draw do
- get "/projects/:project_id/people/:id/update", :to => "people#update", :as => :update_project_person
+ get "/projects/:project_id/people/:id/update", to: "people#update", as: :update_project_person
end
get "/projects/1/people/2/update"
assert_equal "people#update", @response.body
- assert_equal "/projects/1/people/2/update", update_project_person_path(:project_id => 1, :id => 2)
+ assert_equal "/projects/1/people/2/update", update_project_person_path(project_id: 1, id: 2)
end
def test_forum_products
draw do
namespace :forum do
- resources :products, :path => "" do
+ resources :products, path: "" do
resources :questions
end
end
@@ -1065,26 +1065,26 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
get "/forum/basecamp"
assert_equal "forum/products#show", @response.body
- assert_equal "/forum/basecamp", forum_product_path(:id => "basecamp")
+ assert_equal "/forum/basecamp", forum_product_path(id: "basecamp")
get "/forum/basecamp/questions"
assert_equal "forum/questions#index", @response.body
- assert_equal "/forum/basecamp/questions", forum_product_questions_path(:product_id => "basecamp")
+ assert_equal "/forum/basecamp/questions", forum_product_questions_path(product_id: "basecamp")
get "/forum/basecamp/questions/1"
assert_equal "forum/questions#show", @response.body
- assert_equal "/forum/basecamp/questions/1", forum_product_question_path(:product_id => "basecamp", :id => 1)
+ assert_equal "/forum/basecamp/questions/1", forum_product_question_path(product_id: "basecamp", id: 1)
end
def test_articles_perma
draw do
- get "articles/:year/:month/:day/:title", :to => "articles#show", :as => :article
+ get "articles/:year/:month/:day/:title", to: "articles#show", as: :article
end
get "/articles/2009/08/18/rails-3"
assert_equal "articles#show", @response.body
- assert_equal "/articles/2009/8/18/rails-3", article_path(:year => 2009, :month => 8, :day => 18, :title => "rails-3")
+ assert_equal "/articles/2009/8/18/rails-3", article_path(year: 2009, month: 8, day: 18, title: "rails-3")
end
def test_account_namespace
@@ -1145,8 +1145,8 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
def test_namespace_with_options
draw do
- namespace :users, :path => "usuarios" do
- root :to => "home#index"
+ namespace :users, path: "usuarios" do
+ root to: "home#index"
end
end
@@ -1300,9 +1300,9 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
def test_articles_with_id
draw do
controller :articles do
- scope "/articles", :as => "article" do
- scope :path => "/:title", :title => /[a-z]+/, :as => :with_title do
- get "/:id", :action => :with_id, :as => ""
+ scope "/articles", as: "article" do
+ scope path: "/:title", title: /[a-z]+/, as: :with_title do
+ get "/:id", action: :with_id, as: ""
end
end
end
@@ -1314,12 +1314,12 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
get "/articles/123/1"
assert_equal "pass", @response.headers["X-Cascade"]
- assert_equal "/articles/rails/1", article_with_title_path(:title => "rails", :id => 1)
+ assert_equal "/articles/rails/1", article_with_title_path(title: "rails", id: 1)
end
def test_access_token_rooms
draw do
- scope ":access_token", :constraints => { :access_token => /\w{5,5}/ } do
+ scope ":access_token", constraints: { access_token: /\w{5,5}/ } do
resources :rooms
end
end
@@ -1336,7 +1336,7 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
def test_root
draw do
- root :to => "projects#index"
+ root to: "projects#index"
end
assert_equal "/", root_path
@@ -1346,24 +1346,24 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
def test_scoped_root
draw do
- scope "(:locale)", :locale => /en|pl/ do
- root :to => "projects#index"
+ scope "(:locale)", locale: /en|pl/ do
+ root to: "projects#index"
end
end
- assert_equal "/en", root_path(:locale => "en")
+ assert_equal "/en", root_path(locale: "en")
get "/en"
assert_equal "projects#index", @response.body
end
def test_scoped_root_as_name
draw do
- scope "(:locale)", :locale => /en|pl/ do
- root :to => "projects#index", :as => "projects"
+ scope "(:locale)", locale: /en|pl/ do
+ root to: "projects#index", as: "projects"
end
end
- assert_equal "/en", projects_path(:locale => "en")
+ assert_equal "/en", projects_path(locale: "en")
assert_equal "/", projects_path
get "/en"
assert_equal "projects#index", @response.body
@@ -1432,7 +1432,7 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
def test_match_with_many_paths_containing_a_slash
draw do
- get "get/first", "get/second", "get/third", :to => "get#show"
+ get "get/first", "get/second", "get/third", to: "get#show"
end
get "/get/first"
@@ -1561,7 +1561,7 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
draw do
namespace :account do
ActiveSupport::Deprecation.silence do
- get ":action/callback", :action => /twitter|github/, :controller => "callbacks", :as => :callback
+ get ":action/callback", action: /twitter|github/, controller: "callbacks", as: :callback
end
end
end
@@ -1596,7 +1596,7 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
def test_redirect_with_complete_url_and_status
draw do
- get "account/google" => redirect("http://www.google.com/", :status => 302)
+ get "account/google" => redirect("http://www.google.com/", status: 302)
end
get "/account/google"
@@ -1605,7 +1605,7 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
def test_redirect_with_port
draw do
- get "account/login", :to => redirect("/login")
+ get "account/login", to: redirect("/login")
end
previous_host, self.host = self.host, "www.example.com:3000"
@@ -1619,7 +1619,7 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
def test_normalize_namespaced_matches
draw do
namespace :account do
- get "description", :action => :description, :as => "description"
+ get "description", action: :description, as: "description"
end
end
@@ -1632,7 +1632,7 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
def test_namespaced_roots
draw do
namespace :account do
- root :to => "account#index"
+ root to: "account#index"
end
end
@@ -1643,8 +1643,8 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
def test_optional_scoped_root
draw do
- scope "(:locale)", :locale => /en|pl/ do
- root :to => "projects#index"
+ scope "(:locale)", locale: /en|pl/ do
+ root to: "projects#index"
end
end
@@ -1655,7 +1655,7 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
def test_optional_scoped_path
draw do
- scope "(:locale)", :locale => /en|pl/ do
+ scope "(:locale)", locale: /en|pl/ do
resources :descriptions
end
end
@@ -1681,7 +1681,7 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
def test_nested_optional_scoped_path
draw do
namespace :admin do
- scope "(:locale)", :locale => /en|pl/ do
+ scope "(:locale)", locale: /en|pl/ do
resources :descriptions
end
end
@@ -1707,7 +1707,7 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
def test_nested_optional_path_shorthand
draw do
- scope "(:locale)", :locale => /en|pl/ do
+ scope "(:locale)", locale: /en|pl/ do
get "registrations/new"
end
end
@@ -1721,11 +1721,11 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
def test_default_string_params
draw do
- get "inline_pages/(:id)", :to => "pages#show", :id => "home"
- get "default_pages/(:id)", :to => "pages#show", :defaults => { :id => "home" }
+ get "inline_pages/(:id)", to: "pages#show", id: "home"
+ get "default_pages/(:id)", to: "pages#show", defaults: { id: "home" }
- defaults :id => "home" do
- get "scoped_pages/(:id)", :to => "pages#show"
+ defaults id: "home" do
+ get "scoped_pages/(:id)", to: "pages#show"
end
end
@@ -1779,13 +1779,13 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
def test_resource_constraints
draw do
- resources :products, :constraints => { :id => /\d{4}/ } do
- root :to => "products#root"
- get :favorite, :on => :collection
+ resources :products, constraints: { id: /\d{4}/ } do
+ root to: "products#root"
+ get :favorite, on: :collection
resources :images
end
- resource :dashboard, :constraints => { :ip => /192\.168\.1\.\d{1,3}/ }
+ resource :dashboard, constraints: { ip: /192\.168\.1\.\d{1,3}/ }
end
get "/products/1"
@@ -1813,7 +1813,7 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
def test_root_works_in_the_resources_scope
draw do
resources :products do
- root :to => "products#root"
+ root to: "products#root"
end
end
@@ -1824,7 +1824,7 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
def test_module_scope
draw do
- resource :token, :module => :api
+ resource :token, module: :api
end
get "/token"
@@ -1834,7 +1834,7 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
def test_path_scope
draw do
- scope :path => "api" do
+ scope path: "api" do
resource :me
get "/" => "mes#index"
end
@@ -1850,7 +1850,7 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
def test_symbol_scope
draw do
- scope :path => "api" do
+ scope path: "api" do
scope :v2 do
resource :me, as: "v2_me"
get "/" => "mes#index"
@@ -1884,13 +1884,13 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
assert_equal "foo#bar", @response.body
assert_equal "http://www.example.com/whatever/foo/bar/1",
- url_for(:controller => "foo", :action => "bar", :id => 1)
+ url_for(controller: "foo", action: "bar", id: 1)
end
def test_url_generator_for_namespaced_generic_route
draw do
ActiveSupport::Deprecation.silence do
- get "whatever/:controller(/:action(/:id))", :id => /\d+/
+ get "whatever/:controller(/:action(/:id))", id: /\d+/
end
end
@@ -1901,10 +1901,10 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
assert_equal "foo/bar#show", @response.body
assert_equal "http://www.example.com/whatever/foo/bar/show",
- url_for(:controller => "foo/bar", :action => "show")
+ url_for(controller: "foo/bar", action: "show")
assert_equal "http://www.example.com/whatever/foo/bar/show/1",
- url_for(:controller => "foo/bar", :action => "show", :id => "1")
+ url_for(controller: "foo/bar", action: "show", id: "1")
end
def test_resource_new_actions
@@ -1915,16 +1915,16 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
end
end
- scope "pt", :as => "pt" do
- resources :projects, :path_names => { :new => "novo" }, :path => "projetos" do
- post :preview, :on => :new
+ scope "pt", as: "pt" do
+ resources :projects, path_names: { new: "novo" }, path: "projetos" do
+ post :preview, on: :new
end
- resource :admin, :path_names => { :new => "novo" }, :path => "administrador" do
- post :preview, :on => :new
+ resource :admin, path_names: { new: "novo" }, path: "administrador" do
+ post :preview, on: :new
end
- resources :products, :path_names => { :new => "novo" } do
+ resources :products, path_names: { new: "novo" } do
new do
post :preview
end
@@ -1962,7 +1962,7 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
def test_resource_merges_options_from_scope
draw do
- scope :only => :show do
+ scope only: :show do
resource :account
end
end
@@ -1975,7 +1975,7 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
def test_resources_merges_options_from_scope
draw do
- scope :only => [:index, :show] do
+ scope only: [:index, :show] do
resources :products do
resources :images
end
@@ -2004,7 +2004,7 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
end
end
- resources :threads, :shallow => true do
+ resources :threads, shallow: true do
resource :owner
resources :messages do
resources :comments do
@@ -2026,39 +2026,39 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
get "/api/teams/1"
assert_equal "api/teams#show", @response.body
- assert_equal "/api/teams/1", api_team_path(:id => "1")
+ assert_equal "/api/teams/1", api_team_path(id: "1")
get "/api/teams/1/edit"
assert_equal "api/teams#edit", @response.body
- assert_equal "/api/teams/1/edit", edit_api_team_path(:id => "1")
+ assert_equal "/api/teams/1/edit", edit_api_team_path(id: "1")
get "/api/teams/1/players"
assert_equal "api/players#index", @response.body
- assert_equal "/api/teams/1/players", api_team_players_path(:team_id => "1")
+ assert_equal "/api/teams/1/players", api_team_players_path(team_id: "1")
get "/api/teams/1/players/new"
assert_equal "api/players#new", @response.body
- assert_equal "/api/teams/1/players/new", new_api_team_player_path(:team_id => "1")
+ assert_equal "/api/teams/1/players/new", new_api_team_player_path(team_id: "1")
get "/api/players/2"
assert_equal "api/players#show", @response.body
- assert_equal "/api/players/2", api_player_path(:id => "2")
+ assert_equal "/api/players/2", api_player_path(id: "2")
get "/api/players/2/edit"
assert_equal "api/players#edit", @response.body
- assert_equal "/api/players/2/edit", edit_api_player_path(:id => "2")
+ assert_equal "/api/players/2/edit", edit_api_player_path(id: "2")
get "/api/teams/1/captain"
assert_equal "api/captains#show", @response.body
- assert_equal "/api/teams/1/captain", api_team_captain_path(:team_id => "1")
+ assert_equal "/api/teams/1/captain", api_team_captain_path(team_id: "1")
get "/api/teams/1/captain/new"
assert_equal "api/captains#new", @response.body
- assert_equal "/api/teams/1/captain/new", new_api_team_captain_path(:team_id => "1")
+ assert_equal "/api/teams/1/captain/new", new_api_team_captain_path(team_id: "1")
get "/api/teams/1/captain/edit"
assert_equal "api/captains#edit", @response.body
- assert_equal "/api/teams/1/captain/edit", edit_api_team_captain_path(:team_id => "1")
+ assert_equal "/api/teams/1/captain/edit", edit_api_team_captain_path(team_id: "1")
get "/threads"
assert_equal "threads#index", @response.body
@@ -2070,51 +2070,51 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
get "/threads/1"
assert_equal "threads#show", @response.body
- assert_equal "/threads/1", thread_path(:id => "1")
+ assert_equal "/threads/1", thread_path(id: "1")
get "/threads/1/edit"
assert_equal "threads#edit", @response.body
- assert_equal "/threads/1/edit", edit_thread_path(:id => "1")
+ assert_equal "/threads/1/edit", edit_thread_path(id: "1")
get "/threads/1/owner"
assert_equal "owners#show", @response.body
- assert_equal "/threads/1/owner", thread_owner_path(:thread_id => "1")
+ assert_equal "/threads/1/owner", thread_owner_path(thread_id: "1")
get "/threads/1/messages"
assert_equal "messages#index", @response.body
- assert_equal "/threads/1/messages", thread_messages_path(:thread_id => "1")
+ assert_equal "/threads/1/messages", thread_messages_path(thread_id: "1")
get "/threads/1/messages/new"
assert_equal "messages#new", @response.body
- assert_equal "/threads/1/messages/new", new_thread_message_path(:thread_id => "1")
+ assert_equal "/threads/1/messages/new", new_thread_message_path(thread_id: "1")
get "/messages/2"
assert_equal "messages#show", @response.body
- assert_equal "/messages/2", message_path(:id => "2")
+ assert_equal "/messages/2", message_path(id: "2")
get "/messages/2/edit"
assert_equal "messages#edit", @response.body
- assert_equal "/messages/2/edit", edit_message_path(:id => "2")
+ assert_equal "/messages/2/edit", edit_message_path(id: "2")
get "/messages/2/comments"
assert_equal "comments#index", @response.body
- assert_equal "/messages/2/comments", message_comments_path(:message_id => "2")
+ assert_equal "/messages/2/comments", message_comments_path(message_id: "2")
get "/messages/2/comments/new"
assert_equal "comments#new", @response.body
- assert_equal "/messages/2/comments/new", new_message_comment_path(:message_id => "2")
+ assert_equal "/messages/2/comments/new", new_message_comment_path(message_id: "2")
get "/comments/3"
assert_equal "comments#show", @response.body
- assert_equal "/comments/3", comment_path(:id => "3")
+ assert_equal "/comments/3", comment_path(id: "3")
get "/comments/3/edit"
assert_equal "comments#edit", @response.body
- assert_equal "/comments/3/edit", edit_comment_path(:id => "3")
+ assert_equal "/comments/3/edit", edit_comment_path(id: "3")
post "/comments/3/preview"
assert_equal "comments#preview", @response.body
- assert_equal "/comments/3/preview", preview_comment_path(:id => "3")
+ assert_equal "/comments/3/preview", preview_comment_path(id: "3")
end
def test_shallow_nested_resources_inside_resource
@@ -2167,8 +2167,8 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
assert_equal "/comments/1", comment_path("1")
assert_equal "/blogs/new", new_blog_path
- assert_equal "/blogs/1/posts/new", new_blog_post_path(:blog_id => 1)
- assert_equal "/blogs/1/posts/2/comments/new", new_blog_post_comment_path(:blog_id => 1, :post_id => 2)
+ assert_equal "/blogs/1/posts/new", new_blog_post_path(blog_id: 1)
+ assert_equal "/blogs/1/posts/2/comments/new", new_blog_post_comment_path(blog_id: 1, post_id: 2)
end
def test_direct_children_of_shallow_resources
@@ -2206,23 +2206,23 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
get "/hello/notes/1/trackbacks"
assert_equal "trackbacks#index", @response.body
- assert_equal "/hello/notes/1/trackbacks", note_trackbacks_path(:note_id => 1)
+ assert_equal "/hello/notes/1/trackbacks", note_trackbacks_path(note_id: 1)
get "/hello/notes/1/edit"
assert_equal "notes#edit", @response.body
- assert_equal "/hello/notes/1/edit", edit_note_path(:id => "1")
+ assert_equal "/hello/notes/1/edit", edit_note_path(id: "1")
get "/hello/notes/1/trackbacks/new"
assert_equal "trackbacks#new", @response.body
- assert_equal "/hello/notes/1/trackbacks/new", new_note_trackback_path(:note_id => 1)
+ assert_equal "/hello/notes/1/trackbacks/new", new_note_trackback_path(note_id: 1)
get "/hello/trackbacks/1"
assert_equal "trackbacks#show", @response.body
- assert_equal "/hello/trackbacks/1", trackback_path(:id => "1")
+ assert_equal "/hello/trackbacks/1", trackback_path(id: "1")
get "/hello/trackbacks/1/edit"
assert_equal "trackbacks#edit", @response.body
- assert_equal "/hello/trackbacks/1/edit", edit_trackback_path(:id => "1")
+ assert_equal "/hello/trackbacks/1/edit", edit_trackback_path(id: "1")
put "/hello/trackbacks/1"
assert_equal "trackbacks#update", @response.body
@@ -2245,7 +2245,7 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
get "/hello/notes/1"
assert_equal "notes#show", @response.body
- assert_equal "/hello/notes/1", note_path(:id => 1)
+ assert_equal "/hello/notes/1", note_path(id: 1)
put "/hello/notes/1"
assert_equal "notes#update", @response.body
@@ -2257,7 +2257,7 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
def test_shallow_option_nested_resources_within_scope
draw do
scope "/hello" do
- resources :notes, :shallow => true do
+ resources :notes, shallow: true do
resources :trackbacks
end
end
@@ -2265,23 +2265,23 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
get "/hello/notes/1/trackbacks"
assert_equal "trackbacks#index", @response.body
- assert_equal "/hello/notes/1/trackbacks", note_trackbacks_path(:note_id => 1)
+ assert_equal "/hello/notes/1/trackbacks", note_trackbacks_path(note_id: 1)
get "/hello/notes/1/edit"
assert_equal "notes#edit", @response.body
- assert_equal "/hello/notes/1/edit", edit_note_path(:id => "1")
+ assert_equal "/hello/notes/1/edit", edit_note_path(id: "1")
get "/hello/notes/1/trackbacks/new"
assert_equal "trackbacks#new", @response.body
- assert_equal "/hello/notes/1/trackbacks/new", new_note_trackback_path(:note_id => 1)
+ assert_equal "/hello/notes/1/trackbacks/new", new_note_trackback_path(note_id: 1)
get "/hello/trackbacks/1"
assert_equal "trackbacks#show", @response.body
- assert_equal "/hello/trackbacks/1", trackback_path(:id => "1")
+ assert_equal "/hello/trackbacks/1", trackback_path(id: "1")
get "/hello/trackbacks/1/edit"
assert_equal "trackbacks#edit", @response.body
- assert_equal "/hello/trackbacks/1/edit", edit_trackback_path(:id => "1")
+ assert_equal "/hello/trackbacks/1/edit", edit_trackback_path(id: "1")
put "/hello/trackbacks/1"
assert_equal "trackbacks#update", @response.body
@@ -2304,7 +2304,7 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
get "/hello/notes/1"
assert_equal "notes#show", @response.body
- assert_equal "/hello/notes/1", note_path(:id => 1)
+ assert_equal "/hello/notes/1", note_path(id: 1)
put "/hello/notes/1"
assert_equal "notes#update", @response.body
@@ -2316,8 +2316,8 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
def test_custom_resource_routes_are_scoped
draw do
resources :customers do
- get :recent, :on => :collection
- get "profile", :on => :member
+ get :recent, on: :collection
+ get "profile", on: :member
get "secret/profile" => "customers#secret", :on => :member
post "preview" => "customers#preview", :as => :another_preview, :on => :new
resource :avatar do
@@ -2325,11 +2325,11 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
end
resources :invoices do
get "outstanding" => "invoices#outstanding", :on => :collection
- get "overdue", :action => :overdue, :on => :collection
+ get "overdue", action: :overdue, on: :collection
get "print" => "invoices#print", :as => :print, :on => :member
post "preview" => "invoices#preview", :as => :preview, :on => :new
end
- resources :notes, :shallow => true do
+ resources :notes, shallow: true do
get "preview" => "notes#preview", :as => :preview, :on => :new
get "print" => "notes#print", :as => :print, :on => :member
end
@@ -2345,17 +2345,17 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
end
assert_equal "/customers/recent", recent_customers_path
- assert_equal "/customers/1/profile", profile_customer_path(:id => "1")
- assert_equal "/customers/1/secret/profile", secret_profile_customer_path(:id => "1")
+ assert_equal "/customers/1/profile", profile_customer_path(id: "1")
+ assert_equal "/customers/1/secret/profile", secret_profile_customer_path(id: "1")
assert_equal "/customers/new/preview", another_preview_new_customer_path
- assert_equal "/customers/1/avatar/thumbnail.jpg", thumbnail_customer_avatar_path(:customer_id => "1", :format => :jpg)
- assert_equal "/customers/1/invoices/outstanding", outstanding_customer_invoices_path(:customer_id => "1")
- assert_equal "/customers/1/invoices/2/print", print_customer_invoice_path(:customer_id => "1", :id => "2")
- assert_equal "/customers/1/invoices/new/preview", preview_new_customer_invoice_path(:customer_id => "1")
- assert_equal "/customers/1/notes/new/preview", preview_new_customer_note_path(:customer_id => "1")
- assert_equal "/notes/1/print", print_note_path(:id => "1")
+ assert_equal "/customers/1/avatar/thumbnail.jpg", thumbnail_customer_avatar_path(customer_id: "1", format: :jpg)
+ assert_equal "/customers/1/invoices/outstanding", outstanding_customer_invoices_path(customer_id: "1")
+ assert_equal "/customers/1/invoices/2/print", print_customer_invoice_path(customer_id: "1", id: "2")
+ assert_equal "/customers/1/invoices/new/preview", preview_new_customer_invoice_path(customer_id: "1")
+ assert_equal "/customers/1/notes/new/preview", preview_new_customer_note_path(customer_id: "1")
+ assert_equal "/notes/1/print", print_note_path(id: "1")
assert_equal "/api/customers/recent", recent_api_customers_path
- assert_equal "/api/customers/1/profile", profile_api_customer_path(:id => "1")
+ assert_equal "/api/customers/1/profile", profile_api_customer_path(id: "1")
assert_equal "/api/customers/new/preview", preview_new_api_customer_path
get "/customers/1/invoices/overdue"
@@ -2367,8 +2367,8 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
def test_shallow_nested_routes_ignore_module
draw do
- scope :module => :api do
- resources :errors, :shallow => true do
+ scope module: :api do
+ resources :errors, shallow: true do
resources :notices
end
end
@@ -2376,47 +2376,47 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
get "/errors/1/notices"
assert_equal "api/notices#index", @response.body
- assert_equal "/errors/1/notices", error_notices_path(:error_id => "1")
+ assert_equal "/errors/1/notices", error_notices_path(error_id: "1")
get "/notices/1"
assert_equal "api/notices#show", @response.body
- assert_equal "/notices/1", notice_path(:id => "1")
+ assert_equal "/notices/1", notice_path(id: "1")
end
def test_non_greedy_regexp
draw do
namespace :api do
- scope(":version", :version => /.+/) do
- resources :users, :id => /.+?/, :format => /json|xml/
+ scope(":version", version: /.+/) do
+ resources :users, id: /.+?/, format: /json|xml/
end
end
end
get "/api/1.0/users"
assert_equal "api/users#index", @response.body
- assert_equal "/api/1.0/users", api_users_path(:version => "1.0")
+ assert_equal "/api/1.0/users", api_users_path(version: "1.0")
get "/api/1.0/users.json"
assert_equal "api/users#index", @response.body
assert_equal true, @request.format.json?
- assert_equal "/api/1.0/users.json", api_users_path(:version => "1.0", :format => :json)
+ assert_equal "/api/1.0/users.json", api_users_path(version: "1.0", format: :json)
get "/api/1.0/users/first.last"
assert_equal "api/users#show", @response.body
assert_equal "first.last", @request.params[:id]
- assert_equal "/api/1.0/users/first.last", api_user_path(:version => "1.0", :id => "first.last")
+ assert_equal "/api/1.0/users/first.last", api_user_path(version: "1.0", id: "first.last")
get "/api/1.0/users/first.last.xml"
assert_equal "api/users#show", @response.body
assert_equal "first.last", @request.params[:id]
assert_equal true, @request.format.xml?
- assert_equal "/api/1.0/users/first.last.xml", api_user_path(:version => "1.0", :id => "first.last", :format => :xml)
+ assert_equal "/api/1.0/users/first.last.xml", api_user_path(version: "1.0", id: "first.last", format: :xml)
end
def test_match_without_via
assert_raises(ArgumentError) do
draw do
- match "/foo/bar", :to => "files#show"
+ match "/foo/bar", to: "files#show"
end
end
end
@@ -2424,14 +2424,14 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
def test_match_with_empty_via
assert_raises(ArgumentError) do
draw do
- match "/foo/bar", :to => "files#show", :via => []
+ match "/foo/bar", to: "files#show", via: []
end
end
end
def test_glob_parameter_accepts_regexp
draw do
- get "/:locale/*file.:format", :to => "files#show", :file => /path\/to\/existing\/file/
+ get "/:locale/*file.:format", to: "files#show", file: /path\/to\/existing\/file/
end
get "/en/path/to/existing/file.html"
@@ -2455,12 +2455,12 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
get "/bob/followers"
assert_equal "followers#index", @response.body
assert_equal "http://www.example.com/bob/followers",
- url_for(:controller => "followers", :action => "index", :username => "bob")
+ url_for(controller: "followers", action: "index", username: "bob")
get "/followers"
assert_equal "followers#index", @response.body
assert_equal "http://www.example.com/followers",
- url_for(:controller => "followers", :action => "index", :username => nil)
+ url_for(controller: "followers", action: "index", username: nil)
end
def test_url_generator_for_optional_suffix_static_and_dynamic_segment
@@ -2471,12 +2471,12 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
get "/groups/user/bob"
assert_equal "groups#index", @response.body
assert_equal "http://www.example.com/groups/user/bob",
- url_for(:controller => "groups", :action => "index", :username => "bob")
+ url_for(controller: "groups", action: "index", username: "bob")
get "/groups"
assert_equal "groups#index", @response.body
assert_equal "http://www.example.com/groups",
- url_for(:controller => "groups", :action => "index", :username => nil)
+ url_for(controller: "groups", action: "index", username: nil)
end
def test_url_generator_for_optional_prefix_static_and_dynamic_segment
@@ -2487,12 +2487,12 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
get "/user/bob/photos"
assert_equal "photos#index", @response.body
assert_equal "http://www.example.com/user/bob/photos",
- url_for(:controller => "photos", :action => "index", :username => "bob")
+ url_for(controller: "photos", action: "index", username: "bob")
get "/photos"
assert_equal "photos#index", @response.body
assert_equal "http://www.example.com/photos",
- url_for(:controller => "photos", :action => "index", :username => nil)
+ url_for(controller: "photos", action: "index", username: nil)
end
def test_url_recognition_for_optional_static_segments
@@ -2531,8 +2531,8 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
def test_router_removes_invalid_conditions
draw do
- scope :constraints => { :id => /\d+/ } do
- get "/tickets", :to => "tickets#index", :as => :tickets
+ scope constraints: { id: /\d+/ } do
+ get "/tickets", to: "tickets#index", as: :tickets
end
end
@@ -2543,7 +2543,7 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
def test_constraints_are_merged_from_scope
draw do
- scope :constraints => { :id => /\d{4}/ } do
+ scope constraints: { id: /\d{4}/ } do
resources :movies do
resources :reviews
resource :trailer
@@ -2553,40 +2553,40 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
get "/movies/0001"
assert_equal "movies#show", @response.body
- assert_equal "/movies/0001", movie_path(:id => "0001")
+ assert_equal "/movies/0001", movie_path(id: "0001")
get "/movies/00001"
assert_equal "Not Found", @response.body
- assert_raises(ActionController::UrlGenerationError){ movie_path(:id => "00001") }
+ assert_raises(ActionController::UrlGenerationError){ movie_path(id: "00001") }
get "/movies/0001/reviews"
assert_equal "reviews#index", @response.body
- assert_equal "/movies/0001/reviews", movie_reviews_path(:movie_id => "0001")
+ assert_equal "/movies/0001/reviews", movie_reviews_path(movie_id: "0001")
get "/movies/00001/reviews"
assert_equal "Not Found", @response.body
- assert_raises(ActionController::UrlGenerationError){ movie_reviews_path(:movie_id => "00001") }
+ assert_raises(ActionController::UrlGenerationError){ movie_reviews_path(movie_id: "00001") }
get "/movies/0001/reviews/0001"
assert_equal "reviews#show", @response.body
- assert_equal "/movies/0001/reviews/0001", movie_review_path(:movie_id => "0001", :id => "0001")
+ assert_equal "/movies/0001/reviews/0001", movie_review_path(movie_id: "0001", id: "0001")
get "/movies/00001/reviews/0001"
assert_equal "Not Found", @response.body
- assert_raises(ActionController::UrlGenerationError){ movie_path(:movie_id => "00001", :id => "00001") }
+ assert_raises(ActionController::UrlGenerationError){ movie_path(movie_id: "00001", id: "00001") }
get "/movies/0001/trailer"
assert_equal "trailers#show", @response.body
- assert_equal "/movies/0001/trailer", movie_trailer_path(:movie_id => "0001")
+ assert_equal "/movies/0001/trailer", movie_trailer_path(movie_id: "0001")
get "/movies/00001/trailer"
assert_equal "Not Found", @response.body
- assert_raises(ActionController::UrlGenerationError){ movie_trailer_path(:movie_id => "00001") }
+ assert_raises(ActionController::UrlGenerationError){ movie_trailer_path(movie_id: "00001") }
end
def test_only_should_be_read_from_scope
draw do
- scope :only => [:index, :show] do
+ scope only: [:index, :show] do
namespace :only do
resources :clubs do
resources :players
@@ -2602,28 +2602,28 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
get "/only/clubs/1/edit"
assert_equal "Not Found", @response.body
- assert_raise(NoMethodError) { edit_only_club_path(:id => "1") }
+ assert_raise(NoMethodError) { edit_only_club_path(id: "1") }
get "/only/clubs/1/players"
assert_equal "only/players#index", @response.body
- assert_equal "/only/clubs/1/players", only_club_players_path(:club_id => "1")
+ assert_equal "/only/clubs/1/players", only_club_players_path(club_id: "1")
get "/only/clubs/1/players/2/edit"
assert_equal "Not Found", @response.body
- assert_raise(NoMethodError) { edit_only_club_player_path(:club_id => "1", :id => "2") }
+ assert_raise(NoMethodError) { edit_only_club_player_path(club_id: "1", id: "2") }
get "/only/clubs/1/chairman"
assert_equal "only/chairmen#show", @response.body
- assert_equal "/only/clubs/1/chairman", only_club_chairman_path(:club_id => "1")
+ assert_equal "/only/clubs/1/chairman", only_club_chairman_path(club_id: "1")
get "/only/clubs/1/chairman/edit"
assert_equal "Not Found", @response.body
- assert_raise(NoMethodError) { edit_only_club_chairman_path(:club_id => "1") }
+ assert_raise(NoMethodError) { edit_only_club_chairman_path(club_id: "1") }
end
def test_except_should_be_read_from_scope
draw do
- scope :except => [:new, :create, :edit, :update, :destroy] do
+ scope except: [:new, :create, :edit, :update, :destroy] do
namespace :except do
resources :clubs do
resources :players
@@ -2639,30 +2639,30 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
get "/except/clubs/1/edit"
assert_equal "Not Found", @response.body
- assert_raise(NoMethodError) { edit_except_club_path(:id => "1") }
+ assert_raise(NoMethodError) { edit_except_club_path(id: "1") }
get "/except/clubs/1/players"
assert_equal "except/players#index", @response.body
- assert_equal "/except/clubs/1/players", except_club_players_path(:club_id => "1")
+ assert_equal "/except/clubs/1/players", except_club_players_path(club_id: "1")
get "/except/clubs/1/players/2/edit"
assert_equal "Not Found", @response.body
- assert_raise(NoMethodError) { edit_except_club_player_path(:club_id => "1", :id => "2") }
+ assert_raise(NoMethodError) { edit_except_club_player_path(club_id: "1", id: "2") }
get "/except/clubs/1/chairman"
assert_equal "except/chairmen#show", @response.body
- assert_equal "/except/clubs/1/chairman", except_club_chairman_path(:club_id => "1")
+ assert_equal "/except/clubs/1/chairman", except_club_chairman_path(club_id: "1")
get "/except/clubs/1/chairman/edit"
assert_equal "Not Found", @response.body
- assert_raise(NoMethodError) { edit_except_club_chairman_path(:club_id => "1") }
+ assert_raise(NoMethodError) { edit_except_club_chairman_path(club_id: "1") }
end
def test_only_option_should_override_scope
draw do
- scope :only => :show do
+ scope only: :show do
namespace :only do
- resources :sectors, :only => :index
+ resources :sectors, only: :index
end
end
end
@@ -2673,14 +2673,14 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
get "/only/sectors/1"
assert_equal "Not Found", @response.body
- assert_raise(NoMethodError) { only_sector_path(:id => "1") }
+ assert_raise(NoMethodError) { only_sector_path(id: "1") }
end
def test_only_option_should_not_inherit
draw do
- scope :only => :show do
+ scope only: :show do
namespace :only do
- resources :sectors, :only => :index do
+ resources :sectors, only: :index do
resources :companies
resource :leader
end
@@ -2690,18 +2690,18 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
get "/only/sectors/1/companies/2"
assert_equal "only/companies#show", @response.body
- assert_equal "/only/sectors/1/companies/2", only_sector_company_path(:sector_id => "1", :id => "2")
+ assert_equal "/only/sectors/1/companies/2", only_sector_company_path(sector_id: "1", id: "2")
get "/only/sectors/1/leader"
assert_equal "only/leaders#show", @response.body
- assert_equal "/only/sectors/1/leader", only_sector_leader_path(:sector_id => "1")
+ assert_equal "/only/sectors/1/leader", only_sector_leader_path(sector_id: "1")
end
def test_except_option_should_override_scope
draw do
- scope :except => :index do
+ scope except: :index do
namespace :except do
- resources :sectors, :except => [:show, :update, :destroy]
+ resources :sectors, except: [:show, :update, :destroy]
end
end
end
@@ -2712,14 +2712,14 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
get "/except/sectors/1"
assert_equal "Not Found", @response.body
- assert_raise(NoMethodError) { except_sector_path(:id => "1") }
+ assert_raise(NoMethodError) { except_sector_path(id: "1") }
end
def test_except_option_should_not_inherit
draw do
- scope :except => :index do
+ scope except: :index do
namespace :except do
- resources :sectors, :except => [:show, :update, :destroy] do
+ resources :sectors, except: [:show, :update, :destroy] do
resources :companies
resource :leader
end
@@ -2729,19 +2729,19 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
get "/except/sectors/1/companies/2"
assert_equal "except/companies#show", @response.body
- assert_equal "/except/sectors/1/companies/2", except_sector_company_path(:sector_id => "1", :id => "2")
+ assert_equal "/except/sectors/1/companies/2", except_sector_company_path(sector_id: "1", id: "2")
get "/except/sectors/1/leader"
assert_equal "except/leaders#show", @response.body
- assert_equal "/except/sectors/1/leader", except_sector_leader_path(:sector_id => "1")
+ assert_equal "/except/sectors/1/leader", except_sector_leader_path(sector_id: "1")
end
def test_except_option_should_override_scoped_only
draw do
- scope :only => :show do
+ scope only: :show do
namespace :only do
- resources :sectors, :only => :index do
- resources :managers, :except => [:show, :update, :destroy]
+ resources :sectors, only: :index do
+ resources :managers, except: [:show, :update, :destroy]
end
end
end
@@ -2749,19 +2749,19 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
get "/only/sectors/1/managers"
assert_equal "only/managers#index", @response.body
- assert_equal "/only/sectors/1/managers", only_sector_managers_path(:sector_id => "1")
+ assert_equal "/only/sectors/1/managers", only_sector_managers_path(sector_id: "1")
get "/only/sectors/1/managers/2"
assert_equal "Not Found", @response.body
- assert_raise(NoMethodError) { only_sector_manager_path(:sector_id => "1", :id => "2") }
+ assert_raise(NoMethodError) { only_sector_manager_path(sector_id: "1", id: "2") }
end
def test_only_option_should_override_scoped_except
draw do
- scope :except => :index do
+ scope except: :index do
namespace :except do
- resources :sectors, :except => [:show, :update, :destroy] do
- resources :managers, :only => :index
+ resources :sectors, except: [:show, :update, :destroy] do
+ resources :managers, only: :index
end
end
end
@@ -2769,20 +2769,20 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
get "/except/sectors/1/managers"
assert_equal "except/managers#index", @response.body
- assert_equal "/except/sectors/1/managers", except_sector_managers_path(:sector_id => "1")
+ assert_equal "/except/sectors/1/managers", except_sector_managers_path(sector_id: "1")
get "/except/sectors/1/managers/2"
assert_equal "Not Found", @response.body
- assert_raise(NoMethodError) { except_sector_manager_path(:sector_id => "1", :id => "2") }
+ assert_raise(NoMethodError) { except_sector_manager_path(sector_id: "1", id: "2") }
end
def test_only_scope_should_override_parent_scope
draw do
- scope :only => :show do
+ scope only: :show do
namespace :only do
- resources :sectors, :only => :index do
+ resources :sectors, only: :index do
resources :companies do
- scope :only => :index do
+ scope only: :index do
resources :divisions
end
end
@@ -2793,20 +2793,20 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
get "/only/sectors/1/companies/2/divisions"
assert_equal "only/divisions#index", @response.body
- assert_equal "/only/sectors/1/companies/2/divisions", only_sector_company_divisions_path(:sector_id => "1", :company_id => "2")
+ assert_equal "/only/sectors/1/companies/2/divisions", only_sector_company_divisions_path(sector_id: "1", company_id: "2")
get "/only/sectors/1/companies/2/divisions/3"
assert_equal "Not Found", @response.body
- assert_raise(NoMethodError) { only_sector_company_division_path(:sector_id => "1", :company_id => "2", :id => "3") }
+ assert_raise(NoMethodError) { only_sector_company_division_path(sector_id: "1", company_id: "2", id: "3") }
end
def test_except_scope_should_override_parent_scope
draw do
- scope :except => :index do
+ scope except: :index do
namespace :except do
- resources :sectors, :except => [:show, :update, :destroy] do
+ resources :sectors, except: [:show, :update, :destroy] do
resources :companies do
- scope :except => [:show, :update, :destroy] do
+ scope except: [:show, :update, :destroy] do
resources :divisions
end
end
@@ -2817,20 +2817,20 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
get "/except/sectors/1/companies/2/divisions"
assert_equal "except/divisions#index", @response.body
- assert_equal "/except/sectors/1/companies/2/divisions", except_sector_company_divisions_path(:sector_id => "1", :company_id => "2")
+ assert_equal "/except/sectors/1/companies/2/divisions", except_sector_company_divisions_path(sector_id: "1", company_id: "2")
get "/except/sectors/1/companies/2/divisions/3"
assert_equal "Not Found", @response.body
- assert_raise(NoMethodError) { except_sector_company_division_path(:sector_id => "1", :company_id => "2", :id => "3") }
+ assert_raise(NoMethodError) { except_sector_company_division_path(sector_id: "1", company_id: "2", id: "3") }
end
def test_except_scope_should_override_parent_only_scope
draw do
- scope :only => :show do
+ scope only: :show do
namespace :only do
- resources :sectors, :only => :index do
+ resources :sectors, only: :index do
resources :companies do
- scope :except => [:show, :update, :destroy] do
+ scope except: [:show, :update, :destroy] do
resources :departments
end
end
@@ -2841,20 +2841,20 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
get "/only/sectors/1/companies/2/departments"
assert_equal "only/departments#index", @response.body
- assert_equal "/only/sectors/1/companies/2/departments", only_sector_company_departments_path(:sector_id => "1", :company_id => "2")
+ assert_equal "/only/sectors/1/companies/2/departments", only_sector_company_departments_path(sector_id: "1", company_id: "2")
get "/only/sectors/1/companies/2/departments/3"
assert_equal "Not Found", @response.body
- assert_raise(NoMethodError) { only_sector_company_department_path(:sector_id => "1", :company_id => "2", :id => "3") }
+ assert_raise(NoMethodError) { only_sector_company_department_path(sector_id: "1", company_id: "2", id: "3") }
end
def test_only_scope_should_override_parent_except_scope
draw do
- scope :except => :index do
+ scope except: :index do
namespace :except do
- resources :sectors, :except => [:show, :update, :destroy] do
+ resources :sectors, except: [:show, :update, :destroy] do
resources :companies do
- scope :only => :index do
+ scope only: :index do
resources :departments
end
end
@@ -2865,11 +2865,11 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
get "/except/sectors/1/companies/2/departments"
assert_equal "except/departments#index", @response.body
- assert_equal "/except/sectors/1/companies/2/departments", except_sector_company_departments_path(:sector_id => "1", :company_id => "2")
+ assert_equal "/except/sectors/1/companies/2/departments", except_sector_company_departments_path(sector_id: "1", company_id: "2")
get "/except/sectors/1/companies/2/departments/3"
assert_equal "Not Found", @response.body
- assert_raise(NoMethodError) { except_sector_company_department_path(:sector_id => "1", :company_id => "2", :id => "3") }
+ assert_raise(NoMethodError) { except_sector_company_department_path(sector_id: "1", company_id: "2", id: "3") }
end
def test_resources_are_not_pluralized
@@ -2892,11 +2892,11 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
get "/transport/taxis/1"
assert_equal "transport/taxis#show", @response.body
- assert_equal "/transport/taxis/1", transport_taxi_path(:id => "1")
+ assert_equal "/transport/taxis/1", transport_taxi_path(id: "1")
get "/transport/taxis/1/edit"
assert_equal "transport/taxis#edit", @response.body
- assert_equal "/transport/taxis/1/edit", edit_transport_taxi_path(:id => "1")
+ assert_equal "/transport/taxis/1/edit", edit_transport_taxi_path(id: "1")
put "/transport/taxis/1"
assert_equal "transport/taxis#update", @response.body
@@ -2936,46 +2936,46 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
def test_greedy_resource_id_regexp_doesnt_match_edit_and_custom_action
draw do
- resources :sections, :id => /.+/ do
- get :preview, :on => :member
+ resources :sections, id: /.+/ do
+ get :preview, on: :member
end
end
get "/sections/1/edit"
assert_equal "sections#edit", @response.body
- assert_equal "/sections/1/edit", edit_section_path(:id => "1")
+ assert_equal "/sections/1/edit", edit_section_path(id: "1")
get "/sections/1/preview"
assert_equal "sections#preview", @response.body
- assert_equal "/sections/1/preview", preview_section_path(:id => "1")
+ assert_equal "/sections/1/preview", preview_section_path(id: "1")
end
def test_resource_constraints_are_pushed_to_scope
draw do
namespace :wiki do
- resources :articles, :id => /[^\/]+/ do
- resources :comments, :only => [:create, :new]
+ resources :articles, id: /[^\/]+/ do
+ resources :comments, only: [:create, :new]
end
end
end
get "/wiki/articles/Ruby_on_Rails_3.0"
assert_equal "wiki/articles#show", @response.body
- assert_equal "/wiki/articles/Ruby_on_Rails_3.0", wiki_article_path(:id => "Ruby_on_Rails_3.0")
+ assert_equal "/wiki/articles/Ruby_on_Rails_3.0", wiki_article_path(id: "Ruby_on_Rails_3.0")
get "/wiki/articles/Ruby_on_Rails_3.0/comments/new"
assert_equal "wiki/comments#new", @response.body
- assert_equal "/wiki/articles/Ruby_on_Rails_3.0/comments/new", new_wiki_article_comment_path(:article_id => "Ruby_on_Rails_3.0")
+ assert_equal "/wiki/articles/Ruby_on_Rails_3.0/comments/new", new_wiki_article_comment_path(article_id: "Ruby_on_Rails_3.0")
post "/wiki/articles/Ruby_on_Rails_3.0/comments"
assert_equal "wiki/comments#create", @response.body
- assert_equal "/wiki/articles/Ruby_on_Rails_3.0/comments", wiki_article_comments_path(:article_id => "Ruby_on_Rails_3.0")
+ assert_equal "/wiki/articles/Ruby_on_Rails_3.0/comments", wiki_article_comments_path(article_id: "Ruby_on_Rails_3.0")
end
def test_resources_path_can_be_a_symbol
draw do
- resources :wiki_pages, :path => :pages
- resource :wiki_account, :path => :my_account
+ resources :wiki_pages, path: :pages
+ resource :wiki_account, path: :my_account
end
get "/pages"
@@ -2984,7 +2984,7 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
get "/pages/Ruby_on_Rails"
assert_equal "wiki_pages#show", @response.body
- assert_equal "/pages/Ruby_on_Rails", wiki_page_path(:id => "Ruby_on_Rails")
+ assert_equal "/pages/Ruby_on_Rails", wiki_page_path(id: "Ruby_on_Rails")
get "/my_account"
assert_equal "wiki_accounts#show", @response.body
@@ -2993,7 +2993,7 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
def test_redirect_https
draw do
- get "secure", :to => redirect("/secure/login")
+ get "secure", to: redirect("/secure/login")
end
with_https do
@@ -3004,12 +3004,12 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
def test_path_parameters_is_not_stale
draw do
- scope "/countries/:country", :constraints => lambda { |params, req| %w(all France).include?(params[:country]) } do
- get "/", :to => "countries#index"
- get "/cities", :to => "countries#cities"
+ scope "/countries/:country", constraints: lambda { |params, req| %w(all France).include?(params[:country]) } do
+ get "/", to: "countries#index"
+ get "/cities", to: "countries#cities"
end
- get "/countries/:country/(*other)", :to => redirect{ |params, req| params[:other] ? "/countries/all/#{params[:other]}" : "/countries/all" }
+ get "/countries/:country/(*other)", to: redirect{ |params, req| params[:other] ? "/countries/all/#{params[:other]}" : "/countries/all" }
end
get "/countries/France"
@@ -3028,9 +3028,9 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
def test_constraints_block_not_carried_to_following_routes
draw do
scope "/italians" do
- get "/writers", :to => "italians#writers", :constraints => ::TestRoutingMapper::IpRestrictor
- get "/sculptors", :to => "italians#sculptors"
- get "/painters/:painter", :to => "italians#painters", :constraints => {:painter => /michelangelo/}
+ get "/writers", to: "italians#writers", constraints: ::TestRoutingMapper::IpRestrictor
+ get "/sculptors", to: "italians#sculptors"
+ get "/painters/:painter", to: "italians#painters", constraints: {painter: /michelangelo/}
end
end
@@ -3051,12 +3051,12 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
draw do
resources :customers do
resources :invoices do
- get "aged/:months", :on => :collection, :action => :aged, :as => :aged
+ get "aged/:months", on: :collection, action: :aged, as: :aged
end
- get "inactive", :on => :collection
- post "deactivate", :on => :member
- get "old", :on => :collection, :as => :stale
+ get "inactive", on: :collection
+ post "deactivate", on: :member
+ get "old", on: :collection, as: :stale
end
end
@@ -3066,7 +3066,7 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
post "/customers/1/deactivate"
assert_equal "customers#deactivate", @response.body
- assert_equal "/customers/1/deactivate", deactivate_customer_path(:id => "1")
+ assert_equal "/customers/1/deactivate", deactivate_customer_path(id: "1")
get "/customers/old"
assert_equal "customers#old", @response.body
@@ -3074,7 +3074,7 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
get "/customers/1/invoices/aged/3"
assert_equal "invoices#aged", @response.body
- assert_equal "/customers/1/invoices/aged/3", aged_customer_invoices_path(:customer_id => "1", :months => "3")
+ assert_equal "/customers/1/invoices/aged/3", aged_customer_invoices_path(customer_id: "1", months: "3")
end
def test_route_defined_in_resources_scope_level
@@ -3086,41 +3086,41 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
get "/customers/1/export"
assert_equal "customers#export", @response.body
- assert_equal "/customers/1/export", customer_export_path(:customer_id => "1")
+ assert_equal "/customers/1/export", customer_export_path(customer_id: "1")
end
def test_named_character_classes_in_regexp_constraints
draw do
get "/purchases/:token/:filename",
- :to => "purchases#fetch",
- :token => /[[:alnum:]]{10}/,
- :filename => /(.+)/,
- :as => :purchase
+ to: "purchases#fetch",
+ token: /[[:alnum:]]{10}/,
+ filename: /(.+)/,
+ as: :purchase
end
get "/purchases/315004be7e/Ruby_on_Rails_3.pdf"
assert_equal "purchases#fetch", @response.body
- assert_equal "/purchases/315004be7e/Ruby_on_Rails_3.pdf", purchase_path(:token => "315004be7e", :filename => "Ruby_on_Rails_3.pdf")
+ assert_equal "/purchases/315004be7e/Ruby_on_Rails_3.pdf", purchase_path(token: "315004be7e", filename: "Ruby_on_Rails_3.pdf")
end
def test_nested_resource_constraints
draw do
- resources :lists, :id => /([A-Za-z0-9]{25})|default/ do
- resources :todos, :id => /\d+/
+ resources :lists, id: /([A-Za-z0-9]{25})|default/ do
+ resources :todos, id: /\d+/
end
end
get "/lists/01234012340123401234fffff"
assert_equal "lists#show", @response.body
- assert_equal "/lists/01234012340123401234fffff", list_path(:id => "01234012340123401234fffff")
+ assert_equal "/lists/01234012340123401234fffff", list_path(id: "01234012340123401234fffff")
get "/lists/01234012340123401234fffff/todos/1"
assert_equal "todos#show", @response.body
- assert_equal "/lists/01234012340123401234fffff/todos/1", list_todo_path(:list_id => "01234012340123401234fffff", :id => "1")
+ assert_equal "/lists/01234012340123401234fffff/todos/1", list_todo_path(list_id: "01234012340123401234fffff", id: "1")
get "/lists/2/todos/1"
assert_equal "Not Found", @response.body
- assert_raises(ActionController::UrlGenerationError){ list_todo_path(:list_id => "2", :id => "1") }
+ assert_raises(ActionController::UrlGenerationError){ list_todo_path(list_id: "2", id: "1") }
end
def test_redirect_argument_error
@@ -3143,10 +3143,10 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
def test_explicitly_avoiding_the_named_route
draw do
- scope :as => "routes" do
- get "/c/:id", :as => :collision, :to => "collision#show"
- get "/collision", :to => "collision#show"
- get "/no_collision", :to => "collision#show", :as => nil
+ scope as: "routes" do
+ get "/c/:id", as: :collision, to: "collision#show"
+ get "/collision", to: "collision#show"
+ get "/no_collision", to: "collision#show", as: nil
end
end
@@ -3155,49 +3155,49 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
def test_controller_name_with_leading_slash_raise_error
assert_raise(ArgumentError) do
- draw { get "/feeds/:service", :to => "/feeds#show" }
+ draw { get "/feeds/:service", to: "/feeds#show" }
end
assert_raise(ArgumentError) do
- draw { get "/feeds/:service", :controller => "/feeds", :action => "show" }
+ draw { get "/feeds/:service", controller: "/feeds", action: "show" }
end
assert_raise(ArgumentError) do
- draw { get "/api/feeds/:service", :to => "/api/feeds#show" }
+ draw { get "/api/feeds/:service", to: "/api/feeds#show" }
end
assert_raise(ArgumentError) do
- draw { resources :feeds, :controller => "/feeds" }
+ draw { resources :feeds, controller: "/feeds" }
end
end
def test_invalid_route_name_raises_error
assert_raise(ArgumentError) do
- draw { get "/products", :to => "products#index", :as => "products " }
+ draw { get "/products", to: "products#index", as: "products " }
end
assert_raise(ArgumentError) do
- draw { get "/products", :to => "products#index", :as => " products" }
+ draw { get "/products", to: "products#index", as: " products" }
end
assert_raise(ArgumentError) do
- draw { get "/products", :to => "products#index", :as => "products!" }
+ draw { get "/products", to: "products#index", as: "products!" }
end
assert_raise(ArgumentError) do
- draw { get "/products", :to => "products#index", :as => "products index" }
+ draw { get "/products", to: "products#index", as: "products index" }
end
assert_raise(ArgumentError) do
- draw { get "/products", :to => "products#index", :as => "1products" }
+ draw { get "/products", to: "products#index", as: "1products" }
end
end
def test_duplicate_route_name_raises_error
assert_raise(ArgumentError) do
draw do
- get "/collision", :to => "collision#show", :as => "collision"
- get "/duplicate", :to => "duplicate#show", :as => "collision"
+ get "/collision", to: "collision#show", as: "collision"
+ get "/duplicate", to: "duplicate#show", as: "collision"
end
end
end
@@ -3206,15 +3206,15 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
assert_raise(ArgumentError) do
draw do
resources :collisions
- get "/collision", :to => "collision#show", :as => "collision"
+ get "/collision", to: "collision#show", as: "collision"
end
end
end
def test_nested_route_in_nested_resource
draw do
- resources :posts, :only => [:index, :show] do
- resources :comments, :except => :destroy do
+ resources :posts, only: [:index, :show] do
+ resources :comments, except: :destroy do
get "views" => "comments#views", :as => :views
end
end
@@ -3222,27 +3222,27 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
get "/posts/1/comments/2/views"
assert_equal "comments#views", @response.body
- assert_equal "/posts/1/comments/2/views", post_comment_views_path(:post_id => "1", :comment_id => "2")
+ assert_equal "/posts/1/comments/2/views", post_comment_views_path(post_id: "1", comment_id: "2")
end
def test_root_in_deeply_nested_scope
draw do
- resources :posts, :only => [:index, :show] do
+ resources :posts, only: [:index, :show] do
namespace :admin do
- root :to => "index#index"
+ root to: "index#index"
end
end
end
get "/posts/1/admin"
assert_equal "admin/index#index", @response.body
- assert_equal "/posts/1/admin", post_admin_root_path(:post_id => "1")
+ assert_equal "/posts/1/admin", post_admin_root_path(post_id: "1")
end
def test_custom_param
draw do
- resources :profiles, :param => :username do
- get :details, :on => :member
+ resources :profiles, param: :username do
+ get :details, on: :member
resources :messages
end
end
@@ -3261,8 +3261,8 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
def test_custom_param_constraint
draw do
- resources :profiles, :param => :username, :username => /[a-z]+/ do
- get :details, :on => :member
+ resources :profiles, param: :username, username: /[a-z]+/ do
+ get :details, on: :member
resources :messages
end
end
@@ -3280,8 +3280,8 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
def test_shallow_custom_param
draw do
resources :orders do
- constraints :download => /[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}/ do
- resources :downloads, :param => :download, :shallow => true
+ constraints download: /[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}/ do
+ resources :downloads, param: :download, shallow: true
end
end
end
@@ -3616,7 +3616,7 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
def test_passing_action_parameters_to_url_helpers_raises_error_if_parameters_are_not_permitted
draw do
- root :to => "projects#index"
+ root to: "projects#index"
end
params = ActionController::Parameters.new(id: "1")
@@ -3627,7 +3627,7 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
def test_passing_action_parameters_to_url_helpers_is_allowed_if_parameters_are_permitted
draw do
- root :to => "projects#index"
+ root to: "projects#index"
end
params = ActionController::Parameters.new(id: "1")
params.permit!
@@ -3736,7 +3736,7 @@ class TestAltApp < ActionDispatch::IntegrationTest
end
}.new
AltRoutes.draw do
- get "/" => TestAltApp::XHeader.new, :constraints => {:x_header => /HEADER/}
+ get "/" => TestAltApp::XHeader.new, :constraints => {x_header: /HEADER/}
get "/" => TestAltApp::AltApp.new
end
@@ -3816,7 +3816,7 @@ class TestNamespaceWithControllerOption < ActionDispatch::IntegrationTest
def test_missing_controller
ex = assert_raises(ArgumentError) {
draw do
- get "/foo/bar", :action => :index
+ get "/foo/bar", action: :index
end
}
assert_match(/Missing :controller/, ex.message)
@@ -3825,7 +3825,7 @@ class TestNamespaceWithControllerOption < ActionDispatch::IntegrationTest
def test_missing_controller_with_to
ex = assert_raises(ArgumentError) {
draw do
- get "/foo/bar", :to => "foo"
+ get "/foo/bar", to: "foo"
end
}
assert_match(/Missing :controller/, ex.message)
@@ -3834,7 +3834,7 @@ class TestNamespaceWithControllerOption < ActionDispatch::IntegrationTest
def test_missing_action_on_hash
ex = assert_raises(ArgumentError) {
draw do
- get "/foo/bar", :to => "foo#"
+ get "/foo/bar", to: "foo#"
end
}
assert_match(/Missing :action/, ex.message)
@@ -3843,7 +3843,7 @@ class TestNamespaceWithControllerOption < ActionDispatch::IntegrationTest
def test_valid_controller_options_inside_namespace
draw do
namespace :admin do
- resources :storage_files, :controller => "storage_files"
+ resources :storage_files, controller: "storage_files"
end
end
@@ -3853,7 +3853,7 @@ class TestNamespaceWithControllerOption < ActionDispatch::IntegrationTest
def test_resources_with_valid_namespaced_controller_option
draw do
- resources :storage_files, :controller => "admin/storage_files"
+ resources :storage_files, controller: "admin/storage_files"
end
get "/storage_files"
@@ -3864,7 +3864,7 @@ class TestNamespaceWithControllerOption < ActionDispatch::IntegrationTest
e = assert_raise(ArgumentError) do
draw do
namespace :admin do
- resources :storage_files, :controller => "StorageFiles"
+ resources :storage_files, controller: "StorageFiles"
end
end
end
@@ -3875,7 +3875,7 @@ class TestNamespaceWithControllerOption < ActionDispatch::IntegrationTest
def test_warn_with_ruby_constant_syntax_namespaced_controller_option
e = assert_raise(ArgumentError) do
draw do
- resources :storage_files, :controller => "Admin::StorageFiles"
+ resources :storage_files, controller: "Admin::StorageFiles"
end
end
@@ -3885,7 +3885,7 @@ class TestNamespaceWithControllerOption < ActionDispatch::IntegrationTest
def test_warn_with_ruby_constant_syntax_no_colons
e = assert_raise(ArgumentError) do
draw do
- resources :storage_files, :controller => "Admin"
+ resources :storage_files, controller: "Admin"
end
end
@@ -3903,7 +3903,7 @@ class TestDefaultScope < ActionDispatch::IntegrationTest
end
DefaultScopeRoutes = ActionDispatch::Routing::RouteSet.new
- DefaultScopeRoutes.default_scope = {:module => :blog}
+ DefaultScopeRoutes.default_scope = {module: :blog}
DefaultScopeRoutes.draw do
resources :posts
end
@@ -3978,7 +3978,7 @@ class TestUriPathEscaping < ActionDispatch::IntegrationTest
def app; APP end
test "escapes slash in generated path segment" do
- assert_equal "/a%20b%2Fc+d", segment_path(:segment => "a b/c+d")
+ assert_equal "/a%20b%2Fc+d", segment_path(segment: "a b/c+d")
end
test "unescapes recognized path segment" do
@@ -3987,7 +3987,7 @@ class TestUriPathEscaping < ActionDispatch::IntegrationTest
end
test "does not escape slash in generated path splat" do
- assert_equal "/a%20b/c+d", splat_path(:splat => "a b/c+d")
+ assert_equal "/a%20b/c+d", splat_path(splat: "a b/c+d")
end
test "unescapes recognized path splat" do
@@ -4033,7 +4033,7 @@ class TestMultipleNestedController < ActionDispatch::IntegrationTest
include Routes.url_helpers
def index
- render :inline => "<%= url_for :controller => '/pooh', :action => 'index' %>"
+ render inline: "<%= url_for :controller => '/pooh', :action => 'index' %>"
end
end
end
@@ -4080,7 +4080,7 @@ class TestRedirectInterpolation < ActionDispatch::IntegrationTest
ok = lambda { |env| [200, { "Content-Type" => "text/plain" }, []] }
get "/foo/:id" => redirect("/foo/bar/%{id}")
- get "/bar/:id" => redirect(:path => "/foo/bar/%{id}")
+ get "/bar/:id" => redirect(path: "/foo/bar/%{id}")
get "/baz/:id" => redirect("/baz?id=%{id}&foo=?&bar=1#id-%{id}")
get "/foo/bar/:id" => ok
get "/baz" => ok
@@ -4254,7 +4254,7 @@ class TestNamedRouteUrlHelpers < ActionDispatch::IntegrationTest
Routes = ActionDispatch::Routing::RouteSet.new.tap do |app|
app.draw do
- scope :module => "test_named_route_url_helpers" do
+ scope module: "test_named_route_url_helpers" do
get "/categories/:id" => "categories#show", :as => :category
get "/products/:id" => "products#show", :as => :product
end
@@ -4280,19 +4280,19 @@ class TestUrlConstraints < ActionDispatch::IntegrationTest
app.draw do
ok = lambda { |env| [200, { "Content-Type" => "text/plain" }, []] }
- constraints :subdomain => "admin" do
+ constraints subdomain: "admin" do
get "/" => ok, :as => :admin_root
end
- scope :constraints => { :protocol => "https://" } do
+ scope constraints: { protocol: "https://" } do
get "/" => ok, :as => :secure_root
end
- get "/" => ok, :as => :alternate_root, :constraints => { :port => 8080 }
+ get "/" => ok, :as => :alternate_root, :constraints => { port: 8080 }
- get "/search" => ok, :constraints => { :subdomain => false }
+ get "/search" => ok, :constraints => { subdomain: false }
- get "/logs" => ok, :constraints => { :subdomain => true }
+ get "/logs" => ok, :constraints => { subdomain: true }
end
end
@@ -4350,14 +4350,14 @@ class TestInvalidUrls < ActionDispatch::IntegrationTest
test "invalid UTF-8 encoding returns a 400 Bad Request" do
with_routing do |set|
set.draw do
- get "/bar/:id", :to => redirect("/foo/show/%{id}")
- get "/foo/show(/:id)", :to => "test_invalid_urls/foo#show"
+ get "/bar/:id", to: redirect("/foo/show/%{id}")
+ get "/foo/show(/:id)", to: "test_invalid_urls/foo#show"
ok = lambda { |env| [200, { "Content-Type" => "text/plain" }, []] }
get "/foobar/:id", to: ok
ActiveSupport::Deprecation.silence do
- get "/foo(/:action(/:id))", :controller => "test_invalid_urls/foo"
+ get "/foo(/:action(/:id))", controller: "test_invalid_urls/foo"
get "/:controller(/:action(/:id))"
end
end
@@ -4384,7 +4384,7 @@ class TestOptionalRootSegments < ActionDispatch::IntegrationTest
stub_controllers do |routes|
Routes = routes
Routes.draw do
- get "/(page/:page)", :to => "pages#index", :as => :root
+ get "/(page/:page)", to: "pages#index", as: :root
end
end
@@ -4404,7 +4404,7 @@ class TestOptionalRootSegments < ActionDispatch::IntegrationTest
assert_equal "pages#index", @response.body
assert_equal "1", @request.params[:page]
assert_equal "/page/1", root_path("1")
- assert_equal "/page/1", root_path(:page => "1")
+ assert_equal "/page/1", root_path(page: "1")
end
end
@@ -4413,10 +4413,10 @@ class TestPortConstraints < ActionDispatch::IntegrationTest
app.draw do
ok = lambda { |env| [200, { "Content-Type" => "text/plain" }, []] }
- get "/integer", to: ok, constraints: { :port => 8080 }
- get "/string", to: ok, constraints: { :port => "8080" }
- get "/array", to: ok, constraints: { :port => [8080] }
- get "/regexp", to: ok, constraints: { :port => /8080/ }
+ get "/integer", to: ok, constraints: { port: 8080 }
+ get "/string", to: ok, constraints: { port: "8080" }
+ get "/array", to: ok, constraints: { port: [8080] }
+ get "/regexp", to: ok, constraints: { port: /8080/ }
end
end
@@ -4581,7 +4581,7 @@ class TestRackAppRouteGeneration < ActionDispatch::IntegrationTest
end
assert_raise(ActionController::UrlGenerationError) do
- assert_equal "/de/account?controller=products", url_for(controller: "products", action: "index", :locale => "de", only_path: true)
+ assert_equal "/de/account?controller=products", url_for(controller: "products", action: "index", locale: "de", only_path: true)
end
end
end
@@ -4608,7 +4608,7 @@ class TestRedirectRouteGeneration < ActionDispatch::IntegrationTest
end
assert_raise(ActionController::UrlGenerationError) do
- assert_equal "/de/account?controller=products", url_for(controller: "products", action: "index", :locale => "de", only_path: true)
+ assert_equal "/de/account?controller=products", url_for(controller: "products", action: "index", locale: "de", only_path: true)
end
end
end
diff --git a/actionpack/test/dispatch/session/cache_store_test.rb b/actionpack/test/dispatch/session/cache_store_test.rb
index 96793b3280..5252d93850 100644
--- a/actionpack/test/dispatch/session/cache_store_test.rb
+++ b/actionpack/test/dispatch/session/cache_store_test.rb
@@ -165,13 +165,13 @@ class CacheStoreTest < ActionDispatch::IntegrationTest
with_routing do |set|
set.draw do
ActiveSupport::Deprecation.silence do
- get ":action", :to => ::CacheStoreTest::TestController
+ get ":action", to: ::CacheStoreTest::TestController
end
end
@app = self.class.build_app(set) do |middleware|
@cache = ActiveSupport::Cache::MemoryStore.new
- middleware.use ActionDispatch::Session::CacheStore, :key => "_session_id", :cache => @cache
+ middleware.use ActionDispatch::Session::CacheStore, key: "_session_id", cache: @cache
middleware.delete ActionDispatch::ShowExceptions
end
diff --git a/actionpack/test/dispatch/session/cookie_store_test.rb b/actionpack/test/dispatch/session/cookie_store_test.rb
index c741f486ea..1dbaa2ab00 100644
--- a/actionpack/test/dispatch/session/cookie_store_test.rb
+++ b/actionpack/test/dispatch/session/cookie_store_test.rb
@@ -7,8 +7,8 @@ class CookieStoreTest < ActionDispatch::IntegrationTest
SessionSecret = "b3c631c314c0bbca50c1b2843150fe33"
Generator = ActiveSupport::LegacyKeyGenerator.new(SessionSecret)
- Verifier = ActiveSupport::MessageVerifier.new(SessionSecret, :digest => "SHA1")
- SignedBar = Verifier.generate(:foo => "bar", :session_id => SecureRandom.hex(16))
+ Verifier = ActiveSupport::MessageVerifier.new(SessionSecret, digest: "SHA1")
+ SignedBar = Verifier.generate(foo: "bar", session_id: SecureRandom.hex(16))
class TestController < ActionController::Base
def no_session_access
@@ -105,7 +105,7 @@ class CookieStoreTest < ActionDispatch::IntegrationTest
end
def test_does_not_set_secure_cookies_over_http
- with_test_route_set(:secure => true) do
+ with_test_route_set(secure: true) do
get "/set_session_value"
assert_response :success
assert_equal nil, headers["Set-Cookie"]
@@ -124,7 +124,7 @@ class CookieStoreTest < ActionDispatch::IntegrationTest
end
def test_does_set_secure_cookies_over_https
- with_test_route_set(:secure => true) do
+ with_test_route_set(secure: true) do
get "/set_session_value", headers: { "HTTPS" => "on" }
assert_response :success
assert_equal "_myapp_session=#{response.body}; path=/; secure; HttpOnly",
@@ -271,7 +271,7 @@ class CookieStoreTest < ActionDispatch::IntegrationTest
end
def test_session_store_with_expire_after
- with_test_route_set(:expire_after => 5.hours) do
+ with_test_route_set(expire_after: 5.hours) do
# First request accesses the session
time = Time.local(2008, 4, 24)
cookie_body = nil
@@ -304,7 +304,7 @@ class CookieStoreTest < ActionDispatch::IntegrationTest
end
def test_session_store_with_explicit_domain
- with_test_route_set(:domain => "example.es") do
+ with_test_route_set(domain: "example.es") do
get "/set_session_value"
assert_match(/domain=example\.es/, headers["Set-Cookie"])
headers["Set-Cookie"]
@@ -319,14 +319,14 @@ class CookieStoreTest < ActionDispatch::IntegrationTest
end
def test_session_store_with_nil_domain
- with_test_route_set(:domain => nil) do
+ with_test_route_set(domain: nil) do
get "/set_session_value"
assert_no_match(/domain\=/, headers["Set-Cookie"])
end
end
def test_session_store_with_all_domains
- with_test_route_set(:domain => :all) do
+ with_test_route_set(domain: :all) do
get "/set_session_value"
assert_match(/domain=\.example\.com/, headers["Set-Cookie"])
end
@@ -346,11 +346,11 @@ class CookieStoreTest < ActionDispatch::IntegrationTest
with_routing do |set|
set.draw do
ActiveSupport::Deprecation.silence do
- get ":action", :to => ::CookieStoreTest::TestController
+ get ":action", to: ::CookieStoreTest::TestController
end
end
- options = { :key => SessionKey }.merge!(options)
+ options = { key: SessionKey }.merge!(options)
@app = self.class.build_app(set) do |middleware|
middleware.use ActionDispatch::Session::CookieStore, options
diff --git a/actionpack/test/dispatch/session/mem_cache_store_test.rb b/actionpack/test/dispatch/session/mem_cache_store_test.rb
index 40594ed61d..c2d0719b4e 100644
--- a/actionpack/test/dispatch/session/mem_cache_store_test.rb
+++ b/actionpack/test/dispatch/session/mem_cache_store_test.rb
@@ -188,12 +188,12 @@ class MemCacheStoreTest < ActionDispatch::IntegrationTest
with_routing do |set|
set.draw do
ActiveSupport::Deprecation.silence do
- get ":action", :to => ::MemCacheStoreTest::TestController
+ get ":action", to: ::MemCacheStoreTest::TestController
end
end
@app = self.class.build_app(set) do |middleware|
- middleware.use ActionDispatch::Session::MemCacheStore, :key => "_session_id", :namespace => "mem_cache_store_test:#{SecureRandom.hex(10)}"
+ middleware.use ActionDispatch::Session::MemCacheStore, key: "_session_id", namespace: "mem_cache_store_test:#{SecureRandom.hex(10)}"
middleware.delete ActionDispatch::ShowExceptions
end
diff --git a/actionpack/test/dispatch/test_request_test.rb b/actionpack/test/dispatch/test_request_test.rb
index a27c07389b..9beab1ee07 100644
--- a/actionpack/test/dispatch/test_request_test.rb
+++ b/actionpack/test/dispatch/test_request_test.rb
@@ -49,7 +49,7 @@ class TestRequestTest < ActiveSupport::TestCase
req.cookie_jar.clear
assert_cookies({}, req.cookie_jar)
- req.cookie_jar.update(:user_name => "david")
+ req.cookie_jar.update(user_name: "david")
assert_cookies({"user_name" => "david"}, req.cookie_jar)
end
diff --git a/actionpack/test/dispatch/uploaded_file_test.rb b/actionpack/test/dispatch/uploaded_file_test.rb
index 63d8cda9a0..60d0246a68 100644
--- a/actionpack/test/dispatch/uploaded_file_test.rb
+++ b/actionpack/test/dispatch/uploaded_file_test.rb
@@ -9,81 +9,81 @@ module ActionDispatch
end
def test_original_filename
- uf = Http::UploadedFile.new(:filename => "foo", :tempfile => Object.new)
+ uf = Http::UploadedFile.new(filename: "foo", tempfile: Object.new)
assert_equal "foo", uf.original_filename
end
def test_filename_should_be_in_utf_8
- uf = Http::UploadedFile.new(:filename => "foo", :tempfile => Object.new)
+ uf = Http::UploadedFile.new(filename: "foo", tempfile: Object.new)
assert_equal "UTF-8", uf.original_filename.encoding.to_s
end
def test_filename_should_always_be_in_utf_8
- uf = Http::UploadedFile.new(:filename => "foo".encode(Encoding::SHIFT_JIS),
- :tempfile => Object.new)
+ uf = Http::UploadedFile.new(filename: "foo".encode(Encoding::SHIFT_JIS),
+ tempfile: Object.new)
assert_equal "UTF-8", uf.original_filename.encoding.to_s
end
def test_content_type
- uf = Http::UploadedFile.new(:type => "foo", :tempfile => Object.new)
+ uf = Http::UploadedFile.new(type: "foo", tempfile: Object.new)
assert_equal "foo", uf.content_type
end
def test_headers
- uf = Http::UploadedFile.new(:head => "foo", :tempfile => Object.new)
+ uf = Http::UploadedFile.new(head: "foo", tempfile: Object.new)
assert_equal "foo", uf.headers
end
def test_tempfile
- uf = Http::UploadedFile.new(:tempfile => "foo")
+ uf = Http::UploadedFile.new(tempfile: "foo")
assert_equal "foo", uf.tempfile
end
def test_to_io_returns_the_tempfile
tf = Object.new
- uf = Http::UploadedFile.new(:tempfile => tf)
+ uf = Http::UploadedFile.new(tempfile: tf)
assert_equal tf, uf.to_io
end
def test_delegates_path_to_tempfile
tf = Class.new { def path; "thunderhorse" end }
- uf = Http::UploadedFile.new(:tempfile => tf.new)
+ uf = Http::UploadedFile.new(tempfile: tf.new)
assert_equal "thunderhorse", uf.path
end
def test_delegates_open_to_tempfile
tf = Class.new { def open; "thunderhorse" end }
- uf = Http::UploadedFile.new(:tempfile => tf.new)
+ uf = Http::UploadedFile.new(tempfile: tf.new)
assert_equal "thunderhorse", uf.open
end
def test_delegates_close_to_tempfile
tf = Class.new { def close(unlink_now=false); "thunderhorse" end }
- uf = Http::UploadedFile.new(:tempfile => tf.new)
+ uf = Http::UploadedFile.new(tempfile: tf.new)
assert_equal "thunderhorse", uf.close
end
def test_close_accepts_parameter
tf = Class.new { def close(unlink_now=false); "thunderhorse: #{unlink_now}" end }
- uf = Http::UploadedFile.new(:tempfile => tf.new)
+ uf = Http::UploadedFile.new(tempfile: tf.new)
assert_equal "thunderhorse: true", uf.close(true)
end
def test_delegates_read_to_tempfile
tf = Class.new { def read(length=nil, buffer=nil); "thunderhorse" end }
- uf = Http::UploadedFile.new(:tempfile => tf.new)
+ uf = Http::UploadedFile.new(tempfile: tf.new)
assert_equal "thunderhorse", uf.read
end
def test_delegates_read_to_tempfile_with_params
tf = Class.new { def read(length=nil, buffer=nil); [length, buffer] end }
- uf = Http::UploadedFile.new(:tempfile => tf.new)
+ uf = Http::UploadedFile.new(tempfile: tf.new)
assert_equal %w{ thunder horse }, uf.read(*%w{ thunder horse })
end
def test_delegate_respects_respond_to?
tf = Class.new { def read; yield end; private :read }
- uf = Http::UploadedFile.new(:tempfile => tf.new)
+ uf = Http::UploadedFile.new(tempfile: tf.new)
assert_raises(NoMethodError) do
uf.read
end
@@ -91,13 +91,13 @@ module ActionDispatch
def test_delegate_eof_to_tempfile
tf = Class.new { def eof?; true end; }
- uf = Http::UploadedFile.new(:tempfile => tf.new)
+ uf = Http::UploadedFile.new(tempfile: tf.new)
assert uf.eof?
end
def test_respond_to?
tf = Class.new { def read; yield end }
- uf = Http::UploadedFile.new(:tempfile => tf.new)
+ uf = Http::UploadedFile.new(tempfile: tf.new)
assert uf.respond_to?(:headers), "responds to headers"
assert uf.respond_to?(:read), "responds to read"
end
diff --git a/actionpack/test/dispatch/url_generation_test.rb b/actionpack/test/dispatch/url_generation_test.rb
index 50cd4ef800..b5a792b456 100644
--- a/actionpack/test/dispatch/url_generation_test.rb
+++ b/actionpack/test/dispatch/url_generation_test.rb
@@ -13,7 +13,7 @@ module TestUrlGeneration
end
Routes.draw do
- get "/foo", :to => "my_route_generating#index", :as => :foo
+ get "/foo", to: "my_route_generating#index", as: :foo
resources :bars
@@ -35,7 +35,7 @@ module TestUrlGeneration
end
test "accepting a :script_name option" do
- assert_equal "/bar/foo", foo_path(:script_name => "/bar")
+ assert_equal "/bar/foo", foo_path(script_name: "/bar")
end
test "the request's SCRIPT_NAME takes precedence over the route" do
@@ -50,7 +50,7 @@ module TestUrlGeneration
test "handling http protocol with https set" do
https!
- assert_equal "http://www.example.com/foo", foo_url(:protocol => "http")
+ assert_equal "http://www.example.com/foo", foo_url(protocol: "http")
end
test "extracting protocol from host when protocol not present" do