aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/controller
diff options
context:
space:
mode:
authorJose and Yehuda <wycats@gmail.com>2012-04-24 22:32:09 -0500
committerJose and Yehuda <wycats@gmail.com>2012-04-24 22:52:26 -0500
commit56cdc81c08b1847c5c1f699810a8c3b9ac3715a6 (patch)
treea896641a85a55eab01eb74a129dbcbb09f7f8b6b /actionpack/test/controller
parent0cc32c5fd7f875de61262b430bca23825691899b (diff)
downloadrails-56cdc81c08b1847c5c1f699810a8c3b9ac3715a6.tar.gz
rails-56cdc81c08b1847c5c1f699810a8c3b9ac3715a6.tar.bz2
rails-56cdc81c08b1847c5c1f699810a8c3b9ac3715a6.zip
Remove default match without specified method
In the current router DSL, using the +match+ DSL method will match all verbs for the path to the specified endpoint. In the vast majority of cases, people are currently using +match+ when they actually mean +get+. This introduces security implications. This commit disallows calling +match+ without an HTTP verb constraint by default. To explicitly match all verbs, this commit also adds a :via => :all option to +match+. Closes #5964
Diffstat (limited to 'actionpack/test/controller')
-rw-r--r--actionpack/test/controller/action_pack_assertions_test.rb20
-rw-r--r--actionpack/test/controller/base_test.rb14
-rw-r--r--actionpack/test/controller/caching_test.rb6
-rw-r--r--actionpack/test/controller/flash_test.rb2
-rw-r--r--actionpack/test/controller/integration_test.rb8
-rw-r--r--actionpack/test/controller/mime_responds_test.rb2
-rw-r--r--actionpack/test/controller/new_base/content_type_test.rb2
-rw-r--r--actionpack/test/controller/new_base/render_template_test.rb2
-rw-r--r--actionpack/test/controller/new_base/render_test.rb4
-rw-r--r--actionpack/test/controller/new_base/render_text_test.rb4
-rw-r--r--actionpack/test/controller/redirect_test.rb4
-rw-r--r--actionpack/test/controller/render_test.rb2
-rw-r--r--actionpack/test/controller/render_xml_test.rb2
-rw-r--r--actionpack/test/controller/rescue_test.rb6
-rw-r--r--actionpack/test/controller/resources_test.rb4
-rw-r--r--actionpack/test/controller/routing_test.rb336
-rw-r--r--actionpack/test/controller/test_case_test.rb10
-rw-r--r--actionpack/test/controller/url_for_integration_test.rb32
-rw-r--r--actionpack/test/controller/url_for_test.rb16
-rw-r--r--actionpack/test/controller/url_rewriter_test.rb2
-rw-r--r--actionpack/test/controller/webservice_test.rb2
21 files changed, 240 insertions, 240 deletions
diff --git a/actionpack/test/controller/action_pack_assertions_test.rb b/actionpack/test/controller/action_pack_assertions_test.rb
index 01cafe1aca..b121ca9481 100644
--- a/actionpack/test/controller/action_pack_assertions_test.rb
+++ b/actionpack/test/controller/action_pack_assertions_test.rb
@@ -162,7 +162,7 @@ class ActionPackAssertionsControllerTest < ActionController::TestCase
def test_string_constraint
with_routing do |set|
set.draw do
- match "photos", :to => 'action_pack_assertions#nothing', :constraints => {:subdomain => "admin"}
+ get "photos", :to => 'action_pack_assertions#nothing', :constraints => {:subdomain => "admin"}
end
end
end
@@ -170,9 +170,9 @@ class ActionPackAssertionsControllerTest < ActionController::TestCase
def test_assert_redirect_to_named_route_failure
with_routing do |set|
set.draw do
- match 'route_one', :to => 'action_pack_assertions#nothing', :as => :route_one
- match 'route_two', :to => 'action_pack_assertions#nothing', :id => 'two', :as => :route_two
- match ':controller/:action'
+ get 'route_one', :to => 'action_pack_assertions#nothing', :as => :route_one
+ get 'route_two', :to => 'action_pack_assertions#nothing', :id => 'two', :as => :route_two
+ get ':controller/:action'
end
process :redirect_to_named_route
assert_raise(ActiveSupport::TestCase::Assertion) do
@@ -192,8 +192,8 @@ class ActionPackAssertionsControllerTest < ActionController::TestCase
with_routing do |set|
set.draw do
- match 'admin/inner_module', :to => 'admin/inner_module#index', :as => :admin_inner_module
- match ':controller/:action'
+ get 'admin/inner_module', :to => 'admin/inner_module#index', :as => :admin_inner_module
+ get ':controller/:action'
end
process :redirect_to_index
# redirection is <{"action"=>"index", "controller"=>"admin/admin/inner_module"}>
@@ -206,8 +206,8 @@ class ActionPackAssertionsControllerTest < ActionController::TestCase
with_routing do |set|
set.draw do
- match '/action_pack_assertions/:id', :to => 'action_pack_assertions#index', :as => :top_level
- match ':controller/:action'
+ get '/action_pack_assertions/:id', :to => 'action_pack_assertions#index', :as => :top_level
+ get ':controller/:action'
end
process :redirect_to_top_level_named_route
# assert_redirected_to "http://test.host/action_pack_assertions/foo" would pass because of exact match early return
@@ -221,8 +221,8 @@ class ActionPackAssertionsControllerTest < ActionController::TestCase
with_routing do |set|
set.draw do
# this controller exists in the admin namespace as well which is the only difference from previous test
- match '/user/:id', :to => 'user#index', :as => :top_level
- match ':controller/:action'
+ get '/user/:id', :to => 'user#index', :as => :top_level
+ get ':controller/:action'
end
process :redirect_to_top_level_named_route
# assert_redirected_to top_level_url('foo') would pass because of exact match early return
diff --git a/actionpack/test/controller/base_test.rb b/actionpack/test/controller/base_test.rb
index 2032aca52e..b9513ccff4 100644
--- a/actionpack/test/controller/base_test.rb
+++ b/actionpack/test/controller/base_test.rb
@@ -158,7 +158,7 @@ class UrlOptionsTest < ActionController::TestCase
def test_url_for_query_params_included
rs = ActionDispatch::Routing::RouteSet.new
rs.draw do
- match 'home' => 'pages#home'
+ get 'home' => 'pages#home'
end
options = {
@@ -174,8 +174,8 @@ class UrlOptionsTest < ActionController::TestCase
def test_url_options_override
with_routing do |set|
set.draw do
- match 'from_view', :to => 'url_options#from_view', :as => :from_view
- match ':controller/:action'
+ get 'from_view', :to => 'url_options#from_view', :as => :from_view
+ get ':controller/:action'
end
get :from_view, :route => "from_view_url"
@@ -189,7 +189,7 @@ class UrlOptionsTest < ActionController::TestCase
def test_url_helpers_does_not_become_actions
with_routing do |set|
set.draw do
- match "account/overview"
+ get "account/overview"
end
assert !@controller.class.action_methods.include?("account_overview_path")
@@ -208,8 +208,8 @@ class DefaultUrlOptionsTest < ActionController::TestCase
def test_default_url_options_override
with_routing do |set|
set.draw do
- match 'from_view', :to => 'default_url_options#from_view', :as => :from_view
- match ':controller/:action'
+ get 'from_view', :to => 'default_url_options#from_view', :as => :from_view
+ get ':controller/:action'
end
get :from_view, :route => "from_view_url"
@@ -226,7 +226,7 @@ class DefaultUrlOptionsTest < ActionController::TestCase
scope("/:locale") do
resources :descriptions
end
- match ':controller/:action'
+ get ':controller/:action'
end
get :from_view, :route => "description_path(1)"
diff --git a/actionpack/test/controller/caching_test.rb b/actionpack/test/controller/caching_test.rb
index a42c68a628..e8546cb154 100644
--- a/actionpack/test/controller/caching_test.rb
+++ b/actionpack/test/controller/caching_test.rb
@@ -102,8 +102,8 @@ class PageCachingTest < ActionController::TestCase
def test_page_caching_resources_saves_to_correct_path_with_extension_even_if_default_route
with_routing do |set|
set.draw do
- match 'posts.:format', :to => 'posts#index', :as => :formatted_posts
- match '/', :to => 'posts#index', :as => :main
+ get 'posts.:format', :to => 'posts#index', :as => :formatted_posts
+ get '/', :to => 'posts#index', :as => :main
end
@params[:format] = 'rss'
assert_equal '/posts.rss', @routes.url_for(@params)
@@ -560,7 +560,7 @@ class ActionCacheTest < ActionController::TestCase
def test_xml_version_of_resource_is_treated_as_different_cache
with_routing do |set|
set.draw do
- match ':controller(/:action(.:format))'
+ get ':controller(/:action(.:format))'
end
get :index, :format => 'xml'
diff --git a/actionpack/test/controller/flash_test.rb b/actionpack/test/controller/flash_test.rb
index 37ccc7a4a5..e4b34125ad 100644
--- a/actionpack/test/controller/flash_test.rb
+++ b/actionpack/test/controller/flash_test.rb
@@ -277,7 +277,7 @@ class FlashIntegrationTest < ActionDispatch::IntegrationTest
def with_test_route_set
with_routing do |set|
set.draw do
- match ':action', :to => FlashIntegrationTest::TestController
+ get ':action', :to => FlashIntegrationTest::TestController
end
@app = self.class.build_app(set) do |middleware|
diff --git a/actionpack/test/controller/integration_test.rb b/actionpack/test/controller/integration_test.rb
index 44f033119d..877b91b563 100644
--- a/actionpack/test/controller/integration_test.rb
+++ b/actionpack/test/controller/integration_test.rb
@@ -466,7 +466,7 @@ class IntegrationProcessTest < ActionDispatch::IntegrationTest
end
set.draw do
- match ':action', :to => controller
+ match ':action', :to => controller, :via => [:get, :post]
get 'get/:action', :to => controller
end
@@ -530,10 +530,10 @@ class ApplicationIntegrationTest < ActionDispatch::IntegrationTest
end
routes.draw do
- match '', :to => 'application_integration_test/test#index', :as => :empty_string
+ get '', :to => 'application_integration_test/test#index', :as => :empty_string
- match 'foo', :to => 'application_integration_test/test#index', :as => :foo
- match 'bar', :to => 'application_integration_test/test#index', :as => :bar
+ get 'foo', :to => 'application_integration_test/test#index', :as => :foo
+ get 'bar', :to => 'application_integration_test/test#index', :as => :bar
end
def app
diff --git a/actionpack/test/controller/mime_responds_test.rb b/actionpack/test/controller/mime_responds_test.rb
index 0e4099ddc6..ac056319fc 100644
--- a/actionpack/test/controller/mime_responds_test.rb
+++ b/actionpack/test/controller/mime_responds_test.rb
@@ -1118,7 +1118,7 @@ class RespondWithControllerTest < ActionController::TestCase
resources :quiz_stores do
resources :customers
end
- match ":controller/:action"
+ get ":controller/:action"
end
yield
end
diff --git a/actionpack/test/controller/new_base/content_type_test.rb b/actionpack/test/controller/new_base/content_type_test.rb
index 4b70031c90..9b57641e75 100644
--- a/actionpack/test/controller/new_base/content_type_test.rb
+++ b/actionpack/test/controller/new_base/content_type_test.rb
@@ -43,7 +43,7 @@ module ContentType
test "default response is HTML and UTF8" do
with_routing do |set|
set.draw do
- match ':controller', :action => 'index'
+ get ':controller', :action => 'index'
end
get "/content_type/base"
diff --git a/actionpack/test/controller/new_base/render_template_test.rb b/actionpack/test/controller/new_base/render_template_test.rb
index ade204c387..00c7df2af8 100644
--- a/actionpack/test/controller/new_base/render_template_test.rb
+++ b/actionpack/test/controller/new_base/render_template_test.rb
@@ -164,7 +164,7 @@ module RenderTemplate
test "rendering with implicit layout" do
with_routing do |set|
- set.draw { match ':controller', :action => :index }
+ set.draw { get ':controller', :action => :index }
get "/render_template/with_layout"
diff --git a/actionpack/test/controller/new_base/render_test.rb b/actionpack/test/controller/new_base/render_test.rb
index 60468bf5c7..cc7f12ac6d 100644
--- a/actionpack/test/controller/new_base/render_test.rb
+++ b/actionpack/test/controller/new_base/render_test.rb
@@ -57,7 +57,7 @@ module Render
test "render with blank" do
with_routing do |set|
set.draw do
- match ":controller", :action => 'index'
+ get ":controller", :action => 'index'
end
get "/render/blank_render"
@@ -70,7 +70,7 @@ module Render
test "rendering more than once raises an exception" do
with_routing do |set|
set.draw do
- match ":controller", :action => 'index'
+ get ":controller", :action => 'index'
end
assert_raises(AbstractController::DoubleRenderError) do
diff --git a/actionpack/test/controller/new_base/render_text_test.rb b/actionpack/test/controller/new_base/render_text_test.rb
index 06d500cca7..e0b38b29fa 100644
--- a/actionpack/test/controller/new_base/render_text_test.rb
+++ b/actionpack/test/controller/new_base/render_text_test.rb
@@ -67,7 +67,7 @@ module RenderText
test "rendering text from a action with default options renders the text with the layout" do
with_routing do |set|
- set.draw { match ':controller', :action => 'index' }
+ set.draw { get ':controller', :action => 'index' }
get "/render_text/simple"
assert_body "hello david"
@@ -77,7 +77,7 @@ module RenderText
test "rendering text from a action with default options renders the text without the layout" do
with_routing do |set|
- set.draw { match ':controller', :action => 'index' }
+ set.draw { get ':controller', :action => 'index' }
get "/render_text/with_layout"
diff --git a/actionpack/test/controller/redirect_test.rb b/actionpack/test/controller/redirect_test.rb
index 6dab42d75d..4331333b98 100644
--- a/actionpack/test/controller/redirect_test.rb
+++ b/actionpack/test/controller/redirect_test.rb
@@ -262,7 +262,7 @@ class RedirectTest < ActionController::TestCase
with_routing do |set|
set.draw do
resources :workshops
- match ':controller/:action'
+ get ':controller/:action'
end
get :redirect_to_existing_record
@@ -296,7 +296,7 @@ class RedirectTest < ActionController::TestCase
def test_redirect_to_with_block_and_accepted_options
with_routing do |set|
set.draw do
- match ':controller/:action'
+ get ':controller/:action'
end
get :redirect_to_with_block_and_options
diff --git a/actionpack/test/controller/render_test.rb b/actionpack/test/controller/render_test.rb
index fce13d096c..10f62dad65 100644
--- a/actionpack/test/controller/render_test.rb
+++ b/actionpack/test/controller/render_test.rb
@@ -1188,7 +1188,7 @@ class RenderTest < ActionController::TestCase
with_routing do |set|
set.draw do
resources :customers
- match ':controller/:action'
+ get ':controller/:action'
end
get :head_with_location_object
diff --git a/actionpack/test/controller/render_xml_test.rb b/actionpack/test/controller/render_xml_test.rb
index 8b4f2f5349..4f280c4bec 100644
--- a/actionpack/test/controller/render_xml_test.rb
+++ b/actionpack/test/controller/render_xml_test.rb
@@ -72,7 +72,7 @@ class RenderXmlTest < ActionController::TestCase
with_routing do |set|
set.draw do
resources :customers
- match ':controller/:action'
+ get ':controller/:action'
end
get :render_with_object_location
diff --git a/actionpack/test/controller/rescue_test.rb b/actionpack/test/controller/rescue_test.rb
index 76c3dfe0d4..48e2d6491e 100644
--- a/actionpack/test/controller/rescue_test.rb
+++ b/actionpack/test/controller/rescue_test.rb
@@ -338,9 +338,9 @@ class RescueTest < ActionDispatch::IntegrationTest
def with_test_routing
with_routing do |set|
set.draw do
- match 'foo', :to => ::RescueTest::TestController.action(:foo)
- match 'invalid', :to => ::RescueTest::TestController.action(:invalid)
- match 'b00m', :to => ::RescueTest::TestController.action(:b00m)
+ get 'foo', :to => ::RescueTest::TestController.action(:foo)
+ get 'invalid', :to => ::RescueTest::TestController.action(:invalid)
+ get 'b00m', :to => ::RescueTest::TestController.action(:b00m)
end
yield
end
diff --git a/actionpack/test/controller/resources_test.rb b/actionpack/test/controller/resources_test.rb
index 3c0a5d36ca..9fc875014c 100644
--- a/actionpack/test/controller/resources_test.rb
+++ b/actionpack/test/controller/resources_test.rb
@@ -680,7 +680,7 @@ class ResourcesTest < ActionController::TestCase
scope '/threads/:thread_id' do
resources :messages, :as => 'thread_messages' do
get :search, :on => :collection
- match :preview, :on => :new
+ get :preview, :on => :new
end
end
end
@@ -698,7 +698,7 @@ class ResourcesTest < ActionController::TestCase
scope '/admin' do
resource :account, :as => :admin_account do
get :login, :on => :member
- match :preview, :on => :new
+ get :preview, :on => :new
end
end
end
diff --git a/actionpack/test/controller/routing_test.rb b/actionpack/test/controller/routing_test.rb
index 272a7da8c5..9441b46d47 100644
--- a/actionpack/test/controller/routing_test.rb
+++ b/actionpack/test/controller/routing_test.rb
@@ -17,7 +17,7 @@ class UriReservedCharactersRoutingTest < ActiveSupport::TestCase
def setup
@set = ActionDispatch::Routing::RouteSet.new
@set.draw do
- match ':controller/:action/:variable/*additional'
+ get ':controller/:action/:variable/*additional'
end
safe, unsafe = %w(: @ & = + $ , ;), %w(^ ? # [ ])
@@ -85,7 +85,7 @@ class LegacyRouteSetTests < ActiveSupport::TestCase
def test_symbols_with_dashes
rs.draw do
- match '/:artist/:song-omg', :to => lambda { |env|
+ get '/:artist/:song-omg', :to => lambda { |env|
resp = JSON.dump env[ActionDispatch::Routing::RouteSet::PARAMETERS_KEY]
[200, {}, [resp]]
}
@@ -97,7 +97,7 @@ class LegacyRouteSetTests < ActiveSupport::TestCase
def test_id_with_dash
rs.draw do
- match '/journey/:id', :to => lambda { |env|
+ get '/journey/:id', :to => lambda { |env|
resp = JSON.dump env[ActionDispatch::Routing::RouteSet::PARAMETERS_KEY]
[200, {}, [resp]]
}
@@ -109,7 +109,7 @@ class LegacyRouteSetTests < ActiveSupport::TestCase
def test_dash_with_custom_regexp
rs.draw do
- match '/:artist/:song-omg', :constraints => { :song => /\d+/ }, :to => lambda { |env|
+ get '/:artist/:song-omg', :constraints => { :song => /\d+/ }, :to => lambda { |env|
resp = JSON.dump env[ActionDispatch::Routing::RouteSet::PARAMETERS_KEY]
[200, {}, [resp]]
}
@@ -122,7 +122,7 @@ class LegacyRouteSetTests < ActiveSupport::TestCase
def test_pre_dash
rs.draw do
- match '/:artist/omg-:song', :to => lambda { |env|
+ get '/:artist/omg-:song', :to => lambda { |env|
resp = JSON.dump env[ActionDispatch::Routing::RouteSet::PARAMETERS_KEY]
[200, {}, [resp]]
}
@@ -134,7 +134,7 @@ class LegacyRouteSetTests < ActiveSupport::TestCase
def test_pre_dash_with_custom_regexp
rs.draw do
- match '/:artist/omg-:song', :constraints => { :song => /\d+/ }, :to => lambda { |env|
+ get '/:artist/omg-:song', :constraints => { :song => /\d+/ }, :to => lambda { |env|
resp = JSON.dump env[ActionDispatch::Routing::RouteSet::PARAMETERS_KEY]
[200, {}, [resp]]
}
@@ -147,7 +147,7 @@ class LegacyRouteSetTests < ActiveSupport::TestCase
def test_star_paths_are_greedy
rs.draw do
- match "/*path", :to => lambda { |env|
+ get "/*path", :to => lambda { |env|
x = env["action_dispatch.request.path_parameters"][:path]
[200, {}, [x]]
}, :format => false
@@ -159,7 +159,7 @@ class LegacyRouteSetTests < ActiveSupport::TestCase
def test_star_paths_are_greedy_but_not_too_much
rs.draw do
- match "/*path", :to => lambda { |env|
+ get "/*path", :to => lambda { |env|
x = JSON.dump env["action_dispatch.request.path_parameters"]
[200, {}, [x]]
}
@@ -172,7 +172,7 @@ class LegacyRouteSetTests < ActiveSupport::TestCase
def test_optional_star_paths_are_greedy
rs.draw do
- match "/(*filters)", :to => lambda { |env|
+ get "/(*filters)", :to => lambda { |env|
x = env["action_dispatch.request.path_parameters"][:filters]
[200, {}, [x]]
}, :format => false
@@ -184,7 +184,7 @@ class LegacyRouteSetTests < ActiveSupport::TestCase
def test_optional_star_paths_are_greedy_but_not_too_much
rs.draw do
- match "/(*filters)", :to => lambda { |env|
+ get "/(*filters)", :to => lambda { |env|
x = JSON.dump env["action_dispatch.request.path_parameters"]
[200, {}, [x]]
}
@@ -198,11 +198,11 @@ class LegacyRouteSetTests < ActiveSupport::TestCase
def test_regexp_precidence
@rs.draw do
- match '/whois/:domain', :constraints => {
+ get '/whois/:domain', :constraints => {
:domain => /\w+\.[\w\.]+/ },
:to => lambda { |env| [200, {}, %w{regexp}] }
- match '/whois/:id', :to => lambda { |env| [200, {}, %w{id}] }
+ get '/whois/:id', :to => lambda { |env| [200, {}, %w{id}] }
end
assert_equal 'regexp', get(URI('http://example.org/whois/example.org'))
@@ -217,9 +217,9 @@ class LegacyRouteSetTests < ActiveSupport::TestCase
}
@rs.draw do
- match '/', :constraints => subdomain.new,
+ get '/', :constraints => subdomain.new,
:to => lambda { |env| [200, {}, %w{default}] }
- match '/', :constraints => { :subdomain => 'clients' },
+ get '/', :constraints => { :subdomain => 'clients' },
:to => lambda { |env| [200, {}, %w{clients}] }
end
@@ -229,11 +229,11 @@ class LegacyRouteSetTests < ActiveSupport::TestCase
def test_lambda_constraints
@rs.draw do
- match '/', :constraints => lambda { |req|
+ get '/', :constraints => lambda { |req|
req.subdomain.present? and req.subdomain != "clients" },
:to => lambda { |env| [200, {}, %w{default}] }
- match '/', :constraints => lambda { |req|
+ get '/', :constraints => lambda { |req|
req.subdomain.present? && req.subdomain == "clients" },
:to => lambda { |env| [200, {}, %w{clients}] }
end
@@ -271,7 +271,7 @@ class LegacyRouteSetTests < ActiveSupport::TestCase
end
def test_default_setup
- @rs.draw { match '/:controller(/:action(/:id))' }
+ @rs.draw { get '/:controller(/:action(/:id))' }
assert_equal({:controller => "content", :action => 'index'}, rs.recognize_path("/content"))
assert_equal({:controller => "content", :action => 'list'}, rs.recognize_path("/content/list"))
assert_equal({:controller => "content", :action => 'show', :id => '10'}, rs.recognize_path("/content/show/10"))
@@ -289,21 +289,21 @@ class LegacyRouteSetTests < ActiveSupport::TestCase
def test_ignores_leading_slash
@rs.clear!
- @rs.draw { match '/:controller(/:action(/:id))'}
+ @rs.draw { get '/:controller(/:action(/:id))'}
test_default_setup
end
def test_route_with_colon_first
rs.draw do
- match '/:controller/:action/:id', :action => 'index', :id => nil
- match ':url', :controller => 'tiny_url', :action => 'translate'
+ get '/:controller/:action/:id', :action => 'index', :id => nil
+ get ':url', :controller => 'tiny_url', :action => 'translate'
end
end
def test_route_with_regexp_for_controller
rs.draw do
- match ':controller/:admintoken(/:action(/:id))', :controller => /admin\/.+/
- match '/:controller(/:action(/:id))'
+ get ':controller/:admintoken(/:action(/:id))', :controller => /admin\/.+/
+ get '/:controller(/:action(/:id))'
end
assert_equal({:controller => "admin/user", :admintoken => "foo", :action => "index"},
@@ -317,7 +317,7 @@ class LegacyRouteSetTests < ActiveSupport::TestCase
def test_route_with_regexp_and_captures_for_controller
rs.draw do
- match '/:controller(/:action(/:id))', :controller => /admin\/(accounts|users)/
+ get '/:controller(/:action(/:id))', :controller => /admin\/(accounts|users)/
end
assert_equal({:controller => "admin/accounts", :action => "index"}, rs.recognize_path("/admin/accounts"))
assert_equal({:controller => "admin/users", :action => "index"}, rs.recognize_path("/admin/users"))
@@ -326,7 +326,7 @@ class LegacyRouteSetTests < ActiveSupport::TestCase
def test_route_with_regexp_and_dot
rs.draw do
- match ':controller/:action/:file',
+ get ':controller/:action/:file',
:controller => /admin|user/,
:action => /upload|download/,
:defaults => {:file => nil},
@@ -356,7 +356,7 @@ class LegacyRouteSetTests < ActiveSupport::TestCase
def test_named_route_with_option
rs.draw do
- match 'page/:title' => 'content#show_page', :as => 'page'
+ get 'page/:title' => 'content#show_page', :as => 'page'
end
assert_equal("http://test.host/page/new%20stuff",
@@ -365,7 +365,7 @@ class LegacyRouteSetTests < ActiveSupport::TestCase
def test_named_route_with_default
rs.draw do
- match 'page/:title' => 'content#show_page', :title => 'AboutPage', :as => 'page'
+ get 'page/:title' => 'content#show_page', :title => 'AboutPage', :as => 'page'
end
assert_equal("http://test.host/page/AboutRails",
@@ -375,7 +375,7 @@ class LegacyRouteSetTests < ActiveSupport::TestCase
def test_named_route_with_path_prefix
rs.draw do
scope "my" do
- match 'page' => 'content#show_page', :as => 'page'
+ get 'page' => 'content#show_page', :as => 'page'
end
end
@@ -386,7 +386,7 @@ class LegacyRouteSetTests < ActiveSupport::TestCase
def test_named_route_with_blank_path_prefix
rs.draw do
scope "" do
- match 'page' => 'content#show_page', :as => 'page'
+ get 'page' => 'content#show_page', :as => 'page'
end
end
@@ -396,7 +396,7 @@ class LegacyRouteSetTests < ActiveSupport::TestCase
def test_named_route_with_nested_controller
rs.draw do
- match 'admin/user' => 'admin/user#index', :as => "users"
+ get 'admin/user' => 'admin/user#index', :as => "users"
end
assert_equal("http://test.host/admin/user",
@@ -405,7 +405,7 @@ class LegacyRouteSetTests < ActiveSupport::TestCase
def test_optimised_named_route_with_host
rs.draw do
- match 'page' => 'content#show_page', :as => 'pages', :host => 'foo.com'
+ get 'page' => 'content#show_page', :as => 'pages', :host => 'foo.com'
end
routes = setup_for_named_route
routes.expects(:url_for).with({
@@ -424,7 +424,7 @@ class LegacyRouteSetTests < ActiveSupport::TestCase
def test_named_route_without_hash
rs.draw do
- match ':controller/:action/:id', :as => 'normal'
+ get ':controller/:action/:id', :as => 'normal'
end
end
@@ -448,9 +448,9 @@ class LegacyRouteSetTests < ActiveSupport::TestCase
def test_named_route_with_regexps
rs.draw do
- match 'page/:year/:month/:day/:title' => 'page#show', :as => 'article',
+ get 'page/:year/:month/:day/:title' => 'page#show', :as => 'article',
:year => /\d+/, :month => /\d+/, :day => /\d+/
- match ':controller/:action/:id'
+ get ':controller/:action/:id'
end
routes = setup_for_named_route
@@ -460,7 +460,7 @@ class LegacyRouteSetTests < ActiveSupport::TestCase
end
def test_changing_controller
- @rs.draw { match ':controller/:action/:id' }
+ @rs.draw { get ':controller/:action/:id' }
assert_equal '/admin/stuff/show/10',
url_for(rs, {:controller => 'stuff', :action => 'show', :id => 10},
@@ -469,8 +469,8 @@ class LegacyRouteSetTests < ActiveSupport::TestCase
def test_paths_escaped
rs.draw do
- match 'file/*path' => 'content#show_file', :as => 'path'
- match ':controller/:action/:id'
+ get 'file/*path' => 'content#show_file', :as => 'path'
+ get ':controller/:action/:id'
end
# No + to space in URI escaping, only for query params.
@@ -486,7 +486,7 @@ class LegacyRouteSetTests < ActiveSupport::TestCase
def test_paths_slashes_unescaped_with_ordered_parameters
rs.draw do
- match '/file/*path' => 'content#index', :as => 'path'
+ get '/file/*path' => 'content#index', :as => 'path'
end
# No / to %2F in URI, only for query params.
@@ -495,14 +495,14 @@ class LegacyRouteSetTests < ActiveSupport::TestCase
def test_non_controllers_cannot_be_matched
rs.draw do
- match ':controller/:action/:id'
+ get ':controller/:action/:id'
end
assert_raise(ActionController::RoutingError) { rs.recognize_path("/not_a/show/10") }
end
def test_should_list_options_diff_when_routing_constraints_dont_match
rs.draw do
- match 'post/:id' => 'post#show', :constraints => { :id => /\d+/ }, :as => 'post'
+ get 'post/:id' => 'post#show', :constraints => { :id => /\d+/ }, :as => 'post'
end
assert_raise(ActionController::RoutingError) do
url_for(rs, { :controller => 'post', :action => 'show', :bad_param => "foo", :use_route => "post" })
@@ -511,7 +511,7 @@ class LegacyRouteSetTests < ActiveSupport::TestCase
def test_dynamic_path_allowed
rs.draw do
- match '*path' => 'content#show_file'
+ get '*path' => 'content#show_file'
end
assert_equal '/pages/boo',
@@ -520,7 +520,7 @@ class LegacyRouteSetTests < ActiveSupport::TestCase
def test_dynamic_recall_paths_allowed
rs.draw do
- match '*path' => 'content#show_file'
+ get '*path' => 'content#show_file'
end
assert_equal '/pages/boo',
@@ -529,8 +529,8 @@ class LegacyRouteSetTests < ActiveSupport::TestCase
def test_backwards
rs.draw do
- match 'page/:id(/:action)' => 'pages#show'
- match ':controller(/:action(/:id))'
+ get 'page/:id(/:action)' => 'pages#show'
+ get ':controller(/:action(/:id))'
end
assert_equal '/page/20', url_for(rs, { :id => 20 }, { :controller => 'pages', :action => 'show' })
@@ -540,8 +540,8 @@ class LegacyRouteSetTests < ActiveSupport::TestCase
def test_route_with_fixnum_default
rs.draw do
- match 'page(/:id)' => 'content#show_page', :id => 1
- match ':controller/:action/:id'
+ get 'page(/:id)' => 'content#show_page', :id => 1
+ get ':controller/:action/:id'
end
assert_equal '/page', url_for(rs, { :controller => 'content', :action => 'show_page' })
@@ -557,8 +557,8 @@ class LegacyRouteSetTests < ActiveSupport::TestCase
# For newer revision
def test_route_with_text_default
rs.draw do
- match 'page/:id' => 'content#show_page', :id => 1
- match ':controller/:action/:id'
+ get 'page/:id' => 'content#show_page', :id => 1
+ get ':controller/:action/:id'
end
assert_equal '/page/foo', url_for(rs, { :controller => 'content', :action => 'show_page', :id => 'foo' })
@@ -573,13 +573,13 @@ class LegacyRouteSetTests < ActiveSupport::TestCase
end
def test_action_expiry
- @rs.draw { match ':controller(/:action(/:id))' }
+ @rs.draw { get ':controller(/:action(/:id))' }
assert_equal '/content', url_for(rs, { :controller => 'content' }, { :controller => 'content', :action => 'show' })
end
def test_requirement_should_prevent_optional_id
rs.draw do
- match 'post/:id' => 'post#show', :constraints => {:id => /\d+/}, :as => 'post'
+ get 'post/:id' => 'post#show', :constraints => {:id => /\d+/}, :as => 'post'
end
assert_equal '/post/10', url_for(rs, { :controller => 'post', :action => 'show', :id => 10 })
@@ -591,11 +591,11 @@ class LegacyRouteSetTests < ActiveSupport::TestCase
def test_both_requirement_and_optional
rs.draw do
- match('test(/:year)' => 'post#show', :as => 'blog',
+ get('test(/:year)' => 'post#show', :as => 'blog',
:defaults => { :year => nil },
:constraints => { :year => /\d{4}/ }
)
- match ':controller/:action/:id'
+ get ':controller/:action/:id'
end
assert_equal '/test', url_for(rs, { :controller => 'post', :action => 'show' })
@@ -606,8 +606,8 @@ class LegacyRouteSetTests < ActiveSupport::TestCase
def test_set_to_nil_forgets
rs.draw do
- match 'pages(/:year(/:month(/:day)))' => 'content#list_pages', :month => nil, :day => nil
- match ':controller/:action/:id'
+ get 'pages(/:year(/:month(/:day)))' => 'content#list_pages', :month => nil, :day => nil
+ get ':controller/:action/:id'
end
assert_equal '/pages/2005',
@@ -649,8 +649,8 @@ class LegacyRouteSetTests < ActiveSupport::TestCase
def test_named_route_method
rs.draw do
- match 'categories' => 'content#categories', :as => 'categories'
- match ':controller(/:action(/:id))'
+ get 'categories' => 'content#categories', :as => 'categories'
+ get ':controller(/:action(/:id))'
end
assert_equal '/categories', url_for(rs, { :controller => 'content', :action => 'categories' })
@@ -664,9 +664,9 @@ class LegacyRouteSetTests < ActiveSupport::TestCase
def test_nil_defaults
rs.draw do
- match 'journal' => 'content#list_journal',
+ get 'journal' => 'content#list_journal',
:date => nil, :user_id => nil
- match ':controller/:action/:id'
+ get ':controller/:action/:id'
end
assert_equal '/journal', url_for(rs, {
@@ -698,7 +698,7 @@ class LegacyRouteSetTests < ActiveSupport::TestCase
def test_recognize_array_of_methods
rs.draw do
match '/match' => 'books#get_or_post', :via => [:get, :post]
- match '/match' => 'books#not_get_or_post'
+ put '/match' => 'books#not_get_or_post'
end
params = rs.recognize_path("/match", :method => :post)
@@ -710,10 +710,10 @@ class LegacyRouteSetTests < ActiveSupport::TestCase
def test_subpath_recognized
rs.draw do
- match '/books/:id/edit' => 'subpath_books#edit'
- match '/items/:id/:action' => 'subpath_books'
- match '/posts/new/:action' => 'subpath_books'
- match '/posts/:id' => 'subpath_books#show'
+ get '/books/:id/edit' => 'subpath_books#edit'
+ get '/items/:id/:action' => 'subpath_books'
+ get '/posts/new/:action' => 'subpath_books'
+ get '/posts/:id' => 'subpath_books#show'
end
hash = rs.recognize_path "/books/17/edit"
@@ -735,9 +735,9 @@ class LegacyRouteSetTests < ActiveSupport::TestCase
def test_subpath_generated
rs.draw do
- match '/books/:id/edit' => 'subpath_books#edit'
- match '/items/:id/:action' => 'subpath_books'
- match '/posts/new/:action' => 'subpath_books'
+ get '/books/:id/edit' => 'subpath_books#edit'
+ get '/items/:id/:action' => 'subpath_books'
+ get '/posts/new/:action' => 'subpath_books'
end
assert_equal "/books/7/edit", url_for(rs, { :controller => "subpath_books", :id => 7, :action => "edit" })
@@ -747,7 +747,7 @@ class LegacyRouteSetTests < ActiveSupport::TestCase
def test_failed_constraints_raises_exception_with_violated_constraints
rs.draw do
- match 'foos/:id' => 'foos#show', :as => 'foo_with_requirement', :constraints => { :id => /\d+/ }
+ get 'foos/:id' => 'foos#show', :as => 'foo_with_requirement', :constraints => { :id => /\d+/ }
end
assert_raise(ActionController::RoutingError) do
@@ -758,11 +758,11 @@ class LegacyRouteSetTests < ActiveSupport::TestCase
def test_routes_changed_correctly_after_clear
rs = ::ActionDispatch::Routing::RouteSet.new
rs.draw do
- match 'ca' => 'ca#aa'
- match 'cb' => 'cb#ab'
- match 'cc' => 'cc#ac'
- match ':controller/:action/:id'
- match ':controller/:action/:id.:format'
+ get 'ca' => 'ca#aa'
+ get 'cb' => 'cb#ab'
+ get 'cc' => 'cc#ac'
+ get ':controller/:action/:id'
+ get ':controller/:action/:id.:format'
end
hash = rs.recognize_path "/cc"
@@ -771,10 +771,10 @@ class LegacyRouteSetTests < ActiveSupport::TestCase
assert_equal %w(cc ac), [hash[:controller], hash[:action]]
rs.draw do
- match 'cb' => 'cb#ab'
- match 'cc' => 'cc#ac'
- match ':controller/:action/:id'
- match ':controller/:action/:id.:format'
+ get 'cb' => 'cb#ab'
+ get 'cc' => 'cc#ac'
+ get ':controller/:action/:id'
+ get ':controller/:action/:id.:format'
end
hash = rs.recognize_path "/cc"
@@ -799,29 +799,29 @@ class RouteSetTest < ActiveSupport::TestCase
@default_route_set ||= begin
set = ROUTING::RouteSet.new
set.draw do
- match '/:controller(/:action(/:id))'
+ get '/:controller(/:action(/:id))'
end
set
end
end
def test_generate_extras
- set.draw { match ':controller/(:action(/:id))' }
+ set.draw { get ':controller/(:action(/:id))' }
path, extras = set.generate_extras(:controller => "foo", :action => "bar", :id => 15, :this => "hello", :that => "world")
assert_equal "/foo/bar/15", path
assert_equal %w(that this), extras.map { |e| e.to_s }.sort
end
def test_extra_keys
- set.draw { match ':controller/:action/:id' }
+ set.draw { get ':controller/:action/:id' }
extras = set.extra_keys(:controller => "foo", :action => "bar", :id => 15, :this => "hello", :that => "world")
assert_equal %w(that this), extras.map { |e| e.to_s }.sort
end
def test_generate_extras_not_first
set.draw do
- match ':controller/:action/:id.:format'
- match ':controller/:action/:id'
+ get ':controller/:action/:id.:format'
+ get ':controller/:action/:id'
end
path, extras = set.generate_extras(:controller => "foo", :action => "bar", :id => 15, :this => "hello", :that => "world")
assert_equal "/foo/bar/15", path
@@ -830,8 +830,8 @@ class RouteSetTest < ActiveSupport::TestCase
def test_generate_not_first
set.draw do
- match ':controller/:action/:id.:format'
- match ':controller/:action/:id'
+ get ':controller/:action/:id.:format'
+ get ':controller/:action/:id'
end
assert_equal "/foo/bar/15?this=hello",
url_for(set, { :controller => "foo", :action => "bar", :id => 15, :this => "hello" })
@@ -839,8 +839,8 @@ class RouteSetTest < ActiveSupport::TestCase
def test_extra_keys_not_first
set.draw do
- match ':controller/:action/:id.:format'
- match ':controller/:action/:id'
+ get ':controller/:action/:id.:format'
+ get ':controller/:action/:id'
end
extras = set.extra_keys(:controller => "foo", :action => "bar", :id => 15, :this => "hello", :that => "world")
assert_equal %w(that this), extras.map { |e| e.to_s }.sort
@@ -849,7 +849,7 @@ class RouteSetTest < ActiveSupport::TestCase
def test_draw
assert_equal 0, set.routes.size
set.draw do
- match '/hello/world' => 'a#b'
+ get '/hello/world' => 'a#b'
end
assert_equal 1, set.routes.size
end
@@ -857,7 +857,7 @@ class RouteSetTest < ActiveSupport::TestCase
def test_draw_symbol_controller_name
assert_equal 0, set.routes.size
set.draw do
- match '/users/index' => 'users#index'
+ get '/users/index' => 'users#index'
end
set.recognize_path('/users/index', :method => :get)
assert_equal 1, set.routes.size
@@ -866,7 +866,7 @@ class RouteSetTest < ActiveSupport::TestCase
def test_named_draw
assert_equal 0, set.routes.size
set.draw do
- match '/hello/world' => 'a#b', :as => 'hello'
+ get '/hello/world' => 'a#b', :as => 'hello'
end
assert_equal 1, set.routes.size
assert_equal set.routes.first, set.named_routes[:hello]
@@ -874,18 +874,18 @@ class RouteSetTest < ActiveSupport::TestCase
def test_earlier_named_routes_take_precedence
set.draw do
- match '/hello/world' => 'a#b', :as => 'hello'
- match '/hello' => 'a#b', :as => 'hello'
+ get '/hello/world' => 'a#b', :as => 'hello'
+ get '/hello' => 'a#b', :as => 'hello'
end
assert_equal set.routes.first, set.named_routes[:hello]
end
def setup_named_route_test
set.draw do
- match '/people(/:id)' => 'people#show', :as => 'show'
- match '/people' => 'people#index', :as => 'index'
- match '/people/go/:foo/:bar/joe(/:id)' => 'people#multi', :as => 'multi'
- match '/admin/users' => 'admin/users#index', :as => "users"
+ get '/people(/:id)' => 'people#show', :as => 'show'
+ get '/people' => 'people#index', :as => 'index'
+ get '/people/go/:foo/:bar/joe(/:id)' => 'people#multi', :as => 'multi'
+ get '/admin/users' => 'admin/users#index', :as => "users"
end
MockController.build(set.url_helpers).new
@@ -985,7 +985,7 @@ class RouteSetTest < ActiveSupport::TestCase
def test_draw_default_route
set.draw do
- match '/:controller/:action/:id'
+ get '/:controller/:action/:id'
end
assert_equal 1, set.routes.size
@@ -999,8 +999,8 @@ class RouteSetTest < ActiveSupport::TestCase
def test_route_with_parameter_shell
set.draw do
- match 'page/:id' => 'pages#show', :id => /\d+/
- match '/:controller(/:action(/:id))'
+ get 'page/:id' => 'pages#show', :id => /\d+/
+ get '/:controller(/:action(/:id))'
end
assert_equal({:controller => 'pages', :action => 'index'}, set.recognize_path('/pages'))
@@ -1014,7 +1014,7 @@ class RouteSetTest < ActiveSupport::TestCase
def test_route_constraints_on_request_object_with_anchors_are_valid
assert_nothing_raised do
set.draw do
- match 'page/:id' => 'pages#show', :constraints => { :host => /^foo$/ }
+ get 'page/:id' => 'pages#show', :constraints => { :host => /^foo$/ }
end
end
end
@@ -1022,27 +1022,27 @@ class RouteSetTest < ActiveSupport::TestCase
def test_route_constraints_with_anchor_chars_are_invalid
assert_raise ArgumentError do
set.draw do
- match 'page/:id' => 'pages#show', :id => /^\d+/
+ get 'page/:id' => 'pages#show', :id => /^\d+/
end
end
assert_raise ArgumentError do
set.draw do
- match 'page/:id' => 'pages#show', :id => /\A\d+/
+ get 'page/:id' => 'pages#show', :id => /\A\d+/
end
end
assert_raise ArgumentError do
set.draw do
- match 'page/:id' => 'pages#show', :id => /\d+$/
+ get 'page/:id' => 'pages#show', :id => /\d+$/
end
end
assert_raise ArgumentError do
set.draw do
- match 'page/:id' => 'pages#show', :id => /\d+\Z/
+ get 'page/:id' => 'pages#show', :id => /\d+\Z/
end
end
assert_raise ArgumentError do
set.draw do
- match 'page/:id' => 'pages#show', :id => /\d+\z/
+ get 'page/:id' => 'pages#show', :id => /\d+\z/
end
end
end
@@ -1057,7 +1057,7 @@ class RouteSetTest < ActiveSupport::TestCase
def test_recognize_with_encoded_id_and_regex
set.draw do
- match 'page/:id' => 'pages#show', :id => /[a-zA-Z0-9\+]+/
+ get 'page/:id' => 'pages#show', :id => /[a-zA-Z0-9\+]+/
end
assert_equal({:controller => 'pages', :action => 'show', :id => '10'}, set.recognize_path('/page/10'))
@@ -1128,7 +1128,7 @@ class RouteSetTest < ActiveSupport::TestCase
def test_typo_recognition
set.draw do
- match 'articles/:year/:month/:day/:title' => 'articles#permalink',
+ get 'articles/:year/:month/:day/:title' => 'articles#permalink',
:year => /\d{4}/, :day => /\d{1,2}/, :month => /\d{1,2}/
end
@@ -1143,7 +1143,7 @@ class RouteSetTest < ActiveSupport::TestCase
def test_routing_traversal_does_not_load_extra_classes
assert !Object.const_defined?("Profiler__"), "Profiler should not be loaded"
set.draw do
- match '/profile' => 'profile#index'
+ get '/profile' => 'profile#index'
end
set.recognize_path("/profile") rescue nil
@@ -1177,8 +1177,8 @@ class RouteSetTest < ActiveSupport::TestCase
def test_generate_with_default_action
set.draw do
- match "/people", :controller => "people", :action => "index"
- match "/people/list", :controller => "people", :action => "list"
+ get "/people", :controller => "people", :action => "index"
+ get "/people/list", :controller => "people", :action => "list"
end
url = url_for(set, { :controller => "people", :action => "list" })
@@ -1197,7 +1197,7 @@ class RouteSetTest < ActiveSupport::TestCase
set.draw do
namespace 'api' do
- match 'inventory' => 'products#inventory'
+ get 'inventory' => 'products#inventory'
end
end
@@ -1222,7 +1222,7 @@ class RouteSetTest < ActiveSupport::TestCase
def test_namespace_with_path_prefix
set.draw do
scope :module => "api", :path => "prefix" do
- match 'inventory' => 'products#inventory'
+ get 'inventory' => 'products#inventory'
end
end
@@ -1234,7 +1234,7 @@ class RouteSetTest < ActiveSupport::TestCase
def test_namespace_with_blank_path_prefix
set.draw do
scope :module => "api", :path => "" do
- match 'inventory' => 'products#inventory'
+ get 'inventory' => 'products#inventory'
end
end
@@ -1244,7 +1244,7 @@ class RouteSetTest < ActiveSupport::TestCase
end
def test_generate_changes_controller_module
- set.draw { match ':controller/:action/:id' }
+ set.draw { get ':controller/:action/:id' }
current = { :controller => "bling/bloop", :action => "bap", :id => 9 }
assert_equal "/foo/bar/baz/7",
@@ -1253,7 +1253,7 @@ class RouteSetTest < ActiveSupport::TestCase
def test_id_is_sticky_when_it_ought_to_be
set.draw do
- match ':controller/:id/:action'
+ get ':controller/:id/:action'
end
url = url_for(set, { :action => "destroy" }, { :controller => "people", :action => "show", :id => "7" })
@@ -1262,8 +1262,8 @@ class RouteSetTest < ActiveSupport::TestCase
def test_use_static_path_when_possible
set.draw do
- match 'about' => "welcome#about"
- match ':controller/:action/:id'
+ get 'about' => "welcome#about"
+ get ':controller/:action/:id'
end
url = url_for(set, { :controller => "welcome", :action => "about" },
@@ -1273,7 +1273,7 @@ class RouteSetTest < ActiveSupport::TestCase
end
def test_generate
- set.draw { match ':controller/:action/:id' }
+ set.draw { get ':controller/:action/:id' }
args = { :controller => "foo", :action => "bar", :id => "7", :x => "y" }
assert_equal "/foo/bar/7?x=y", url_for(set, args)
@@ -1284,7 +1284,7 @@ class RouteSetTest < ActiveSupport::TestCase
def test_generate_with_path_prefix
set.draw do
scope "my" do
- match ':controller(/:action(/:id))'
+ get ':controller(/:action(/:id))'
end
end
@@ -1295,7 +1295,7 @@ class RouteSetTest < ActiveSupport::TestCase
def test_generate_with_blank_path_prefix
set.draw do
scope "" do
- match ':controller(/:action(/:id))'
+ get ':controller(/:action(/:id))'
end
end
@@ -1305,9 +1305,9 @@ class RouteSetTest < ActiveSupport::TestCase
def test_named_routes_are_never_relative_to_modules
set.draw do
- match "/connection/manage(/:action)" => 'connection/manage#index'
- match "/connection/connection" => "connection/connection#index"
- match '/connection' => 'connection#index', :as => 'family_connection'
+ get "/connection/manage(/:action)" => 'connection/manage#index'
+ get "/connection/connection" => "connection/connection#index"
+ get '/connection' => 'connection#index', :as => 'family_connection'
end
url = url_for(set, { :controller => "connection" }, { :controller => 'connection/manage' })
@@ -1319,7 +1319,7 @@ class RouteSetTest < ActiveSupport::TestCase
def test_action_left_off_when_id_is_recalled
set.draw do
- match ':controller(/:action(/:id))'
+ get ':controller(/:action(/:id))'
end
assert_equal '/books', url_for(set,
{:controller => 'books', :action => 'index'},
@@ -1329,8 +1329,8 @@ class RouteSetTest < ActiveSupport::TestCase
def test_query_params_will_be_shown_when_recalled
set.draw do
- match 'show_weblog/:parameter' => 'weblog#show'
- match ':controller(/:action(/:id))'
+ get 'show_weblog/:parameter' => 'weblog#show'
+ get ':controller(/:action(/:id))'
end
assert_equal '/weblog/edit?parameter=1', url_for(set,
{:action => 'edit', :parameter => 1},
@@ -1340,7 +1340,7 @@ class RouteSetTest < ActiveSupport::TestCase
def test_format_is_not_inherit
set.draw do
- match '/posts(.:format)' => 'posts#index'
+ get '/posts(.:format)' => 'posts#index'
end
assert_equal '/posts', url_for(set,
@@ -1355,7 +1355,7 @@ class RouteSetTest < ActiveSupport::TestCase
end
def test_expiry_determination_should_consider_values_with_to_param
- set.draw { match 'projects/:project_id/:controller/:action' }
+ set.draw { get 'projects/:project_id/:controller/:action' }
assert_equal '/projects/1/weblog/show', url_for(set,
{ :action => 'show', :project_id => 1 },
{ :controller => 'weblog', :action => 'show', :project_id => '1' })
@@ -1365,7 +1365,7 @@ class RouteSetTest < ActiveSupport::TestCase
set.draw do
resources :projects do
member do
- match 'milestones' => 'milestones#index', :as => 'milestones'
+ get 'milestones' => 'milestones#index', :as => 'milestones'
end
end
end
@@ -1398,7 +1398,7 @@ class RouteSetTest < ActiveSupport::TestCase
def test_route_constraints_with_unsupported_regexp_options_must_error
assert_raise ArgumentError do
set.draw do
- match 'page/:name' => 'pages#show',
+ get 'page/:name' => 'pages#show',
:constraints => { :name => /(david|jamis)/m }
end
end
@@ -1407,13 +1407,13 @@ class RouteSetTest < ActiveSupport::TestCase
def test_route_constraints_with_supported_options_must_not_error
assert_nothing_raised do
set.draw do
- match 'page/:name' => 'pages#show',
+ get 'page/:name' => 'pages#show',
:constraints => { :name => /(david|jamis)/i }
end
end
assert_nothing_raised do
set.draw do
- match 'page/:name' => 'pages#show',
+ get 'page/:name' => 'pages#show',
:constraints => { :name => / # Desperately overcommented regexp
( #Either
david #The Creator
@@ -1427,7 +1427,7 @@ class RouteSetTest < ActiveSupport::TestCase
def test_route_with_subdomain_and_constraints_must_receive_params
name_param = nil
set.draw do
- match 'page/:name' => 'pages#show', :constraints => lambda {|request|
+ get 'page/:name' => 'pages#show', :constraints => lambda {|request|
name_param = request.params[:name]
return true
}
@@ -1439,7 +1439,7 @@ class RouteSetTest < ActiveSupport::TestCase
def test_route_requirement_recognize_with_ignore_case
set.draw do
- match 'page/:name' => 'pages#show',
+ get 'page/:name' => 'pages#show',
:constraints => {:name => /(david|jamis)/i}
end
assert_equal({:controller => 'pages', :action => 'show', :name => 'jamis'}, set.recognize_path('/page/jamis'))
@@ -1451,7 +1451,7 @@ class RouteSetTest < ActiveSupport::TestCase
def test_route_requirement_generate_with_ignore_case
set.draw do
- match 'page/:name' => 'pages#show',
+ get 'page/:name' => 'pages#show',
:constraints => {:name => /(david|jamis)/i}
end
@@ -1466,7 +1466,7 @@ class RouteSetTest < ActiveSupport::TestCase
def test_route_requirement_recognize_with_extended_syntax
set.draw do
- match 'page/:name' => 'pages#show',
+ get 'page/:name' => 'pages#show',
:constraints => {:name => / # Desperately overcommented regexp
( #Either
david #The Creator
@@ -1486,7 +1486,7 @@ class RouteSetTest < ActiveSupport::TestCase
def test_route_requirement_with_xi_modifiers
set.draw do
- match 'page/:name' => 'pages#show',
+ get 'page/:name' => 'pages#show',
:constraints => {:name => / # Desperately overcommented regexp
( #Either
david #The Creator
@@ -1504,8 +1504,8 @@ class RouteSetTest < ActiveSupport::TestCase
def test_routes_with_symbols
set.draw do
- match 'unnamed', :controller => :pages, :action => :show, :name => :as_symbol
- match 'named' , :controller => :pages, :action => :show, :name => :as_symbol, :as => :named
+ get 'unnamed', :controller => :pages, :action => :show, :name => :as_symbol
+ get 'named' , :controller => :pages, :action => :show, :name => :as_symbol, :as => :named
end
assert_equal({:controller => 'pages', :action => 'show', :name => :as_symbol}, set.recognize_path('/unnamed'))
assert_equal({:controller => 'pages', :action => 'show', :name => :as_symbol}, set.recognize_path('/named'))
@@ -1513,8 +1513,8 @@ class RouteSetTest < ActiveSupport::TestCase
def test_regexp_chunk_should_add_question_mark_for_optionals
set.draw do
- match '/' => 'foo#index'
- match '/hello' => 'bar#index'
+ get '/' => 'foo#index'
+ get '/hello' => 'bar#index'
end
assert_equal '/', url_for(set, { :controller => 'foo' })
@@ -1526,7 +1526,7 @@ class RouteSetTest < ActiveSupport::TestCase
def test_assign_route_options_with_anchor_chars
set.draw do
- match '/cars/:action/:person/:car/', :controller => 'cars'
+ get '/cars/:action/:person/:car/', :controller => 'cars'
end
assert_equal '/cars/buy/1/2', url_for(set, { :controller => 'cars', :action => 'buy', :person => '1', :car => '2' })
@@ -1536,7 +1536,7 @@ class RouteSetTest < ActiveSupport::TestCase
def test_segmentation_of_dot_path
set.draw do
- match '/books/:action.rss', :controller => 'books'
+ get '/books/:action.rss', :controller => 'books'
end
assert_equal '/books/list.rss', url_for(set, { :controller => 'books', :action => 'list' })
@@ -1546,7 +1546,7 @@ class RouteSetTest < ActiveSupport::TestCase
def test_segmentation_of_dynamic_dot_path
set.draw do
- match '/books(/:action(.:format))', :controller => 'books'
+ get '/books(/:action(.:format))', :controller => 'books'
end
assert_equal '/books/list.rss', url_for(set, { :controller => 'books', :action => 'list', :format => 'rss' })
@@ -1562,7 +1562,7 @@ class RouteSetTest < ActiveSupport::TestCase
def test_slashes_are_implied
@set = nil
- set.draw { match("/:controller(/:action(/:id))") }
+ set.draw { get("/:controller(/:action(/:id))") }
assert_equal '/content', url_for(set, { :controller => 'content', :action => 'index' })
assert_equal '/content/list', url_for(set, { :controller => 'content', :action => 'list' })
@@ -1647,13 +1647,13 @@ class RouteSetTest < ActiveSupport::TestCase
def test_generate_with_default_params
set.draw do
- match 'dummy/page/:page' => 'dummy#show'
- match 'dummy/dots/page.:page' => 'dummy#dots'
- match 'ibocorp(/:page)' => 'ibocorp#show',
+ get 'dummy/page/:page' => 'dummy#show'
+ get 'dummy/dots/page.:page' => 'dummy#dots'
+ get 'ibocorp(/:page)' => 'ibocorp#show',
:constraints => { :page => /\d+/ },
:defaults => { :page => 1 }
- match ':controller/:action/:id'
+ get ':controller/:action/:id'
end
assert_equal '/ibocorp', url_for(set, { :controller => 'ibocorp', :action => "show", :page => 1 })
@@ -1661,17 +1661,17 @@ class RouteSetTest < ActiveSupport::TestCase
def test_generate_with_optional_params_recalls_last_request
set.draw do
- match "blog/", :controller => "blog", :action => "index"
+ get "blog/", :controller => "blog", :action => "index"
- match "blog(/:year(/:month(/:day)))",
+ get "blog(/:year(/:month(/:day)))",
:controller => "blog",
:action => "show_date",
:constraints => { :year => /(19|20)\d\d/, :month => /[01]?\d/, :day => /[0-3]?\d/ },
:day => nil, :month => nil
- match "blog/show/:id", :controller => "blog", :action => "show", :id => /\d+/
- match "blog/:controller/:action(/:id)"
- match "*anything", :controller => "blog", :action => "unknown_request"
+ get "blog/show/:id", :controller => "blog", :action => "show", :id => /\d+/
+ get "blog/:controller/:action(/:id)"
+ get "*anything", :controller => "blog", :action => "unknown_request"
end
assert_equal({:controller => "blog", :action => "index"}, set.recognize_path("/blog"))
@@ -1719,7 +1719,7 @@ class RackMountIntegrationTests < ActiveSupport::TestCase
root :to => 'users#index'
end
- match '/blog(/:year(/:month(/:day)))' => 'posts#show_date',
+ get '/blog(/:year(/:month(/:day)))' => 'posts#show_date',
:constraints => {
:year => /(19|20)\d\d/,
:month => /[01]?\d/,
@@ -1728,37 +1728,37 @@ class RackMountIntegrationTests < ActiveSupport::TestCase
:day => nil,
:month => nil
- match 'archive/:year', :controller => 'archive', :action => 'index',
+ get 'archive/:year', :controller => 'archive', :action => 'index',
:defaults => { :year => nil },
:constraints => { :year => /\d{4}/ },
:as => "blog"
resources :people
- match 'legacy/people' => "people#index", :legacy => "true"
+ get 'legacy/people' => "people#index", :legacy => "true"
- match 'symbols', :controller => :symbols, :action => :show, :name => :as_symbol
- match 'id_default(/:id)' => "foo#id_default", :id => 1
+ get 'symbols', :controller => :symbols, :action => :show, :name => :as_symbol
+ get 'id_default(/:id)' => "foo#id_default", :id => 1
match 'get_or_post' => "foo#get_or_post", :via => [:get, :post]
- match 'optional/:optional' => "posts#index"
- match 'projects/:project_id' => "project#index", :as => "project"
- match 'clients' => "projects#index"
+ get 'optional/:optional' => "posts#index"
+ get 'projects/:project_id' => "project#index", :as => "project"
+ get 'clients' => "projects#index"
- match 'ignorecase/geocode/:postalcode' => 'geocode#show', :postalcode => /hx\d\d-\d[a-z]{2}/i
- match 'extended/geocode/:postalcode' => 'geocode#show',:constraints => {
+ get 'ignorecase/geocode/:postalcode' => 'geocode#show', :postalcode => /hx\d\d-\d[a-z]{2}/i
+ get 'extended/geocode/:postalcode' => 'geocode#show',:constraints => {
:postalcode => /# Postcode format
\d{5} #Prefix
(-\d{4})? #Suffix
/x
}, :as => "geocode"
- match 'news(.:format)' => "news#index"
+ get 'news(.:format)' => "news#index"
- match 'comment/:id(/:action)' => "comments#show"
- match 'ws/:controller(/:action(/:id))', :ws => true
- match 'account(/:action)' => "account#subscription"
- match 'pages/:page_id/:controller(/:action(/:id))'
- match ':controller/ping', :action => 'ping'
- match ':controller(/:action(/:id))(.:format)'
+ get 'comment/:id(/:action)' => "comments#show"
+ get 'ws/:controller(/:action(/:id))', :ws => true
+ get 'account(/:action)' => "account#subscription"
+ get 'pages/:page_id/:controller(/:action(/:id))'
+ get ':controller/ping', :action => 'ping'
+ match ':controller(/:action(/:id))(.:format)', :via => :all
root :to => "news#index"
}
diff --git a/actionpack/test/controller/test_case_test.rb b/actionpack/test/controller/test_case_test.rb
index ecba9fed22..e8411bae0c 100644
--- a/actionpack/test/controller/test_case_test.rb
+++ b/actionpack/test/controller/test_case_test.rb
@@ -138,7 +138,7 @@ XML
@request.env['PATH_INFO'] = nil
@routes = ActionDispatch::Routing::RouteSet.new.tap do |r|
r.draw do
- match ':controller(/:action(/:id))'
+ get ':controller(/:action(/:id))'
end
end
end
@@ -524,7 +524,7 @@ XML
with_routing do |set|
set.draw do
namespace :admin do
- match 'user' => 'user#index'
+ get 'user' => 'user#index'
end
end
@@ -534,7 +534,7 @@ XML
def test_assert_routing_with_glob
with_routing do |set|
- set.draw { match('*path' => "pages#show") }
+ set.draw { get('*path' => "pages#show") }
assert_routing('/company/about', { :controller => 'pages', :action => 'show', :path => 'company/about' })
end
end
@@ -585,8 +585,8 @@ XML
def test_array_path_parameter_handled_properly
with_routing do |set|
set.draw do
- match 'file/*path', :to => 'test_case_test/test#test_params'
- match ':controller/:action'
+ get 'file/*path', :to => 'test_case_test/test#test_params'
+ get ':controller/:action'
end
get :test_params, :path => ['hello', 'world']
diff --git a/actionpack/test/controller/url_for_integration_test.rb b/actionpack/test/controller/url_for_integration_test.rb
index 451ea6027d..6c2311e7a5 100644
--- a/actionpack/test/controller/url_for_integration_test.rb
+++ b/actionpack/test/controller/url_for_integration_test.rb
@@ -18,7 +18,7 @@ module ActionPack
root :to => 'users#index'
end
- match '/blog(/:year(/:month(/:day)))' => 'posts#show_date',
+ get '/blog(/:year(/:month(/:day)))' => 'posts#show_date',
:constraints => {
:year => /(19|20)\d\d/,
:month => /[01]?\d/,
@@ -27,7 +27,7 @@ module ActionPack
:day => nil,
:month => nil
- match 'archive/:year', :controller => 'archive', :action => 'index',
+ get 'archive/:year', :controller => 'archive', :action => 'index',
:defaults => { :year => nil },
:constraints => { :year => /\d{4}/ },
:as => "blog"
@@ -35,29 +35,29 @@ module ActionPack
resources :people
#match 'legacy/people' => "people#index", :legacy => "true"
- match 'symbols', :controller => :symbols, :action => :show, :name => :as_symbol
- match 'id_default(/:id)' => "foo#id_default", :id => 1
+ get 'symbols', :controller => :symbols, :action => :show, :name => :as_symbol
+ get 'id_default(/:id)' => "foo#id_default", :id => 1
match 'get_or_post' => "foo#get_or_post", :via => [:get, :post]
- match 'optional/:optional' => "posts#index"
- match 'projects/:project_id' => "project#index", :as => "project"
- match 'clients' => "projects#index"
+ get 'optional/:optional' => "posts#index"
+ get 'projects/:project_id' => "project#index", :as => "project"
+ get 'clients' => "projects#index"
- match 'ignorecase/geocode/:postalcode' => 'geocode#show', :postalcode => /hx\d\d-\d[a-z]{2}/i
- match 'extended/geocode/:postalcode' => 'geocode#show',:constraints => {
+ get 'ignorecase/geocode/:postalcode' => 'geocode#show', :postalcode => /hx\d\d-\d[a-z]{2}/i
+ get 'extended/geocode/:postalcode' => 'geocode#show',:constraints => {
:postalcode => /# Postcode format
\d{5} #Prefix
(-\d{4})? #Suffix
/x
}, :as => "geocode"
- match 'news(.:format)' => "news#index"
+ get 'news(.:format)' => "news#index"
- match 'comment/:id(/:action)' => "comments#show"
- match 'ws/:controller(/:action(/:id))', :ws => true
- match 'account(/:action)' => "account#subscription"
- match 'pages/:page_id/:controller(/:action(/:id))'
- match ':controller/ping', :action => 'ping'
- match ':controller(/:action(/:id))(.:format)'
+ get 'comment/:id(/:action)' => "comments#show"
+ get 'ws/:controller(/:action(/:id))', :ws => true
+ get 'account(/:action)' => "account#subscription"
+ get 'pages/:page_id/:controller(/:action(/:id))'
+ get ':controller/ping', :action => 'ping'
+ get ':controller(/:action(/:id))(.:format)'
root :to => "news#index"
}
diff --git a/actionpack/test/controller/url_for_test.rb b/actionpack/test/controller/url_for_test.rb
index aa233d6135..b2cb5f80d5 100644
--- a/actionpack/test/controller/url_for_test.rb
+++ b/actionpack/test/controller/url_for_test.rb
@@ -5,7 +5,7 @@ module AbstractController
class UrlForTests < ActionController::TestCase
class W
- include ActionDispatch::Routing::RouteSet.new.tap { |r| r.draw { match ':controller(/:action(/:id(.:format)))' } }.url_helpers
+ include ActionDispatch::Routing::RouteSet.new.tap { |r| r.draw { get ':controller(/:action(/:id(.:format)))' } }.url_helpers
end
def teardown
@@ -210,8 +210,8 @@ module AbstractController
def test_named_routes
with_routing do |set|
set.draw do
- match 'this/is/verbose', :to => 'home#index', :as => :no_args
- match 'home/sweet/home/:user', :to => 'home#index', :as => :home
+ get 'this/is/verbose', :to => 'home#index', :as => :no_args
+ get 'home/sweet/home/:user', :to => 'home#index', :as => :home
end
# We need to create a new class in order to install the new named route.
@@ -231,7 +231,7 @@ module AbstractController
def test_relative_url_root_is_respected_for_named_routes
with_routing do |set|
set.draw do
- match '/home/sweet/home/:user', :to => 'home#index', :as => :home
+ get '/home/sweet/home/:user', :to => 'home#index', :as => :home
end
kls = Class.new { include set.url_helpers }
@@ -245,8 +245,8 @@ module AbstractController
def test_only_path
with_routing do |set|
set.draw do
- match 'home/sweet/home/:user', :to => 'home#index', :as => :home
- match ':controller/:action/:id'
+ get 'home/sweet/home/:user', :to => 'home#index', :as => :home
+ get ':controller/:action/:id'
end
# We need to create a new class in order to install the new named route.
@@ -313,8 +313,8 @@ module AbstractController
def test_named_routes_with_nil_keys
with_routing do |set|
set.draw do
- match 'posts.:format', :to => 'posts#index', :as => :posts
- match '/', :to => 'posts#index', :as => :main
+ get 'posts.:format', :to => 'posts#index', :as => :posts
+ get '/', :to => 'posts#index', :as => :main
end
# We need to create a new class in order to install the new named route.
diff --git a/actionpack/test/controller/url_rewriter_test.rb b/actionpack/test/controller/url_rewriter_test.rb
index f88903b10e..cc3706aeee 100644
--- a/actionpack/test/controller/url_rewriter_test.rb
+++ b/actionpack/test/controller/url_rewriter_test.rb
@@ -21,7 +21,7 @@ class UrlRewriterTests < ActionController::TestCase
@rewriter = Rewriter.new(@request) #.new(@request, @params)
@routes = ActionDispatch::Routing::RouteSet.new.tap do |r|
r.draw do
- match ':controller(/:action(/:id))'
+ get ':controller(/:action(/:id))'
end
end
end
diff --git a/actionpack/test/controller/webservice_test.rb b/actionpack/test/controller/webservice_test.rb
index 351e61eeae..c0b9833603 100644
--- a/actionpack/test/controller/webservice_test.rb
+++ b/actionpack/test/controller/webservice_test.rb
@@ -254,7 +254,7 @@ class WebServiceTest < ActionDispatch::IntegrationTest
def with_test_route_set
with_routing do |set|
set.draw do
- match '/', :to => 'web_service_test/test#assign_parameters'
+ match '/', :to => 'web_service_test/test#assign_parameters', :via => :all
end
yield
end