aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/dispatch/routing_test.rb
diff options
context:
space:
mode:
authorDave Rogers <david.t.rogers@gmail.com>2011-07-24 17:21:26 -0700
committerDave Rogers <david.t.rogers@gmail.com>2011-07-25 09:59:53 -0700
commit4dc42f53539a5d1020c49dd61bad2276adc277bf (patch)
tree47b261fd9b708e83c4f46d4acc33918398f89ecb /actionpack/test/dispatch/routing_test.rb
parent02691d3516e68b2de5545ec7a495024a377f89fc (diff)
downloadrails-4dc42f53539a5d1020c49dd61bad2276adc277bf.tar.gz
rails-4dc42f53539a5d1020c49dd61bad2276adc277bf.tar.bz2
rails-4dc42f53539a5d1020c49dd61bad2276adc277bf.zip
Ensure the constraints block is only applied to the correct route
addresses issue #1907 - any routes that follow a route with a constraints block are inheriting the previous route's constraints.
Diffstat (limited to 'actionpack/test/dispatch/routing_test.rb')
-rw-r--r--actionpack/test/dispatch/routing_test.rb20
1 files changed, 20 insertions, 0 deletions
diff --git a/actionpack/test/dispatch/routing_test.rb b/actionpack/test/dispatch/routing_test.rb
index ba7506721f..1938348375 100644
--- a/actionpack/test/dispatch/routing_test.rb
+++ b/actionpack/test/dispatch/routing_test.rb
@@ -504,6 +504,12 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
match '/countries/:country/(*other)', :to => redirect{ |params, req| params[:other] ? "/countries/all/#{params[:other]}" : '/countries/all' }
match '/:locale/*file.:format', :to => 'files#show', :file => /path\/to\/existing\/file/
+
+ scope '/italians' do
+ match '/writers', :to => 'italians#writers', :constraints => ::TestRoutingMapper::IpRestrictor
+ match '/sculptors', :to => 'italians#sculptors'
+ match '/painters/:painter', :to => 'italians#painters', :constraints => {:painter => /michelangelo/}
+ end
end
end
@@ -2229,6 +2235,20 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
verify_redirect 'http://www.example.com/countries/all/cities'
end
+ def test_constraints_block_not_carried_to_following_routes
+ get '/italians/writers'
+ assert_equal 'Not Found', @response.body
+
+ get '/italians/sculptors'
+ assert_equal 'italians#sculptors', @response.body
+
+ get '/italians/painters/botticelli'
+ assert_equal 'Not Found', @response.body
+
+ get '/italians/painters/michelangelo'
+ assert_equal 'italians#painters', @response.body
+ end
+
def test_custom_resource_actions_defined_using_string
get '/customers/inactive'
assert_equal 'customers#inactive', @response.body