aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/dispatch/routing_test.rb
diff options
context:
space:
mode:
authorAndrew White <andyw@pixeltrix.co.uk>2010-07-06 22:20:06 +0100
committerJosé Valim <jose.valim@gmail.com>2010-07-07 00:11:13 +0200
commitb802a0d4c72fbd605b92e9f403c9b8765a6e480c (patch)
tree060f549840236cc7865d1bd85abf4e61f4ddd71a /actionpack/test/dispatch/routing_test.rb
parentf4be0041c605daad2406ec41fa7dfa4388af5f31 (diff)
downloadrails-b802a0d4c72fbd605b92e9f403c9b8765a6e480c.tar.gz
rails-b802a0d4c72fbd605b92e9f403c9b8765a6e480c.tar.bz2
rails-b802a0d4c72fbd605b92e9f403c9b8765a6e480c.zip
When a dynamic :controller segment is present in the path add a Regexp constraint that allow matching on multiple path segments.
Using a namespace block isn't compatible with dynamic routes so we raise an ArgumentError if we detect a :module present in the scope. [#5052 state:resolved] Signed-off-by: José Valim <jose.valim@gmail.com>
Diffstat (limited to 'actionpack/test/dispatch/routing_test.rb')
-rw-r--r--actionpack/test/dispatch/routing_test.rb36
1 files changed, 25 insertions, 11 deletions
diff --git a/actionpack/test/dispatch/routing_test.rb b/actionpack/test/dispatch/routing_test.rb
index 90d05d4a67..2a014bf976 100644
--- a/actionpack/test/dispatch/routing_test.rb
+++ b/actionpack/test/dispatch/routing_test.rb
@@ -323,7 +323,7 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
end
end
- match "whatever/:controller(/:action(/:id))"
+ match "whatever/:controller(/:action(/:id))", :id => /\d+/
resource :profile do
get :settings
@@ -349,7 +349,6 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
namespace :private do
root :to => redirect('/private/index')
match "index", :to => 'private#index'
- match ":controller(/:action(/:id))"
end
scope :only => [:index, :show] do
@@ -527,15 +526,14 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
end
def test_namespace_with_controller_segment
- with_test_routes do
- get '/private/foo'
- assert_equal 'private/foo#index', @response.body
-
- get '/private/foo/bar'
- assert_equal 'private/foo#bar', @response.body
-
- get '/private/foo/bar/1'
- assert_equal 'private/foo#bar', @response.body
+ assert_raise(ArgumentError) do
+ self.class.stub_controllers do |routes|
+ routes.draw do
+ namespace :admin do
+ match '/:controller(/:action(/:id(.:format)))'
+ end
+ end
+ end
end
end
@@ -1354,6 +1352,22 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
end
end
+ def test_url_generator_for_namespaced_generic_route
+ with_test_routes do
+ get 'whatever/foo/bar/show'
+ assert_equal 'foo/bar#show', @response.body
+
+ get 'whatever/foo/bar/show/1'
+ assert_equal 'foo/bar#show', @response.body
+
+ assert_equal 'http://www.example.com/whatever/foo/bar/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')
+ end
+ end
+
def test_assert_recognizes_account_overview
with_test_routes do
assert_recognizes({:controller => "account", :action => "overview"}, "/account/overview")