aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/dispatch/routing_test.rb
diff options
context:
space:
mode:
authorAndrew White <andyw@pixeltrix.co.uk>2010-08-31 17:02:49 +0100
committerJosé Valim <jose.valim@gmail.com>2010-09-01 10:09:14 +0200
commit02480a897be25c24f59180513d37649a31ad3835 (patch)
treef365ca137c9994a3019a06cbec3574331b585a47 /actionpack/test/dispatch/routing_test.rb
parentdbf82557e46b748e98a0ab6ed4ab6c823cac4dd2 (diff)
downloadrails-02480a897be25c24f59180513d37649a31ad3835.tar.gz
rails-02480a897be25c24f59180513d37649a31ad3835.tar.bz2
rails-02480a897be25c24f59180513d37649a31ad3835.zip
Move implicit nested call before options handling so that nested constraints work [#5513 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.rb18
1 files changed, 18 insertions, 0 deletions
diff --git a/actionpack/test/dispatch/routing_test.rb b/actionpack/test/dispatch/routing_test.rb
index 0eee63e94f..c90c1041ed 100644
--- a/actionpack/test/dispatch/routing_test.rb
+++ b/actionpack/test/dispatch/routing_test.rb
@@ -448,6 +448,10 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
:filename => /(.+)/,
:as => :purchase
+ resources :lists, :id => /([A-Za-z0-9]{25})|default/ do
+ resources :todos, :id => /\d+/
+ end
+
scope '/countries/:country', :constraints => lambda { |params, req| %[all France].include?(params[:country]) } do
match '/', :to => 'countries#index'
match '/cities', :to => 'countries#cities'
@@ -2110,6 +2114,20 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
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
+ get '/lists/01234012340123401234fffff'
+ assert_equal 'lists#show', @response.body
+ 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')
+
+ get '/lists/2/todos/1'
+ assert_equal 'Not Found', @response.body
+ assert_raises(ActionController::RoutingError){ list_todo_path(:list_id => '2', :id => '1') }
+ end
+
private
def with_test_routes
yield