From 27619e34d42183f24c80648ee7a46b7fee348327 Mon Sep 17 00:00:00 2001 From: Andrew White Date: Fri, 20 Jul 2012 09:59:37 +0100 Subject: Support constraints on resource custom params when nesting The Mapper looks for a :id constraint in the scope to see whether it should apply a constraint for nested resources. Since #5581 added support for resource params other than :id, we need to check for a constraint on the parent resource's param name and not assume it's :id. --- actionpack/test/dispatch/routing_test.rb | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'actionpack/test') diff --git a/actionpack/test/dispatch/routing_test.rb b/actionpack/test/dispatch/routing_test.rb index a42ac60917..6c360cc1fc 100644 --- a/actionpack/test/dispatch/routing_test.rb +++ b/actionpack/test/dispatch/routing_test.rb @@ -482,7 +482,7 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest get :preview, :on => :member end - resources :profiles, :param => :username do + resources :profiles, :param => :username, :username => /[a-z]+/ do get :details, :on => :member resources :messages end @@ -2243,6 +2243,17 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest assert_equal '34', @request.params[:id] end + def test_custom_param_constraint + get '/profiles/bob1' + assert_equal 404, @response.status + + get '/profiles/bob1/details' + assert_equal 404, @response.status + + get '/profiles/bob1/messages/34' + assert_equal 404, @response.status + end + private def with_https old_https = https? -- cgit v1.2.3