aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/dispatch/routing_test.rb
diff options
context:
space:
mode:
authorXavier Noria <fxn@hashref.com>2016-08-06 19:35:13 +0200
committerXavier Noria <fxn@hashref.com>2016-08-06 19:35:13 +0200
commit5b6eb1d58b48fada298215b2cccda89f993890c3 (patch)
treea48010fd8c35588540f50df257a76347091aca12 /actionpack/test/dispatch/routing_test.rb
parent12a70404cd164008879e63cc320356e6afee3adc (diff)
downloadrails-5b6eb1d58b48fada298215b2cccda89f993890c3.tar.gz
rails-5b6eb1d58b48fada298215b2cccda89f993890c3.tar.bz2
rails-5b6eb1d58b48fada298215b2cccda89f993890c3.zip
modernizes hash syntax in actionpack
Diffstat (limited to 'actionpack/test/dispatch/routing_test.rb')
-rw-r--r--actionpack/test/dispatch/routing_test.rb816
1 files changed, 408 insertions, 408 deletions
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