diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2014-05-30 15:54:56 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2014-06-03 11:33:53 -0700 |
commit | a21707116aab2a0b1038c719635eaf3d737ad644 (patch) | |
tree | 9989abd69c5c2b14ad3440934c5522c998a4f175 /actionpack | |
parent | 522038aa9dc7d9759520d63b1c9d13086bdb3a21 (diff) | |
download | rails-a21707116aab2a0b1038c719635eaf3d737ad644.tar.gz rails-a21707116aab2a0b1038c719635eaf3d737ad644.tar.bz2 rails-a21707116aab2a0b1038c719635eaf3d737ad644.zip |
add tests for nested lambda constraints
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/test/controller/routing_test.rb | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/actionpack/test/controller/routing_test.rb b/actionpack/test/controller/routing_test.rb index 9dc6d77012..660589a86e 100644 --- a/actionpack/test/controller/routing_test.rb +++ b/actionpack/test/controller/routing_test.rb @@ -243,6 +243,33 @@ class LegacyRouteSetTests < ActiveSupport::TestCase assert_equal 'clients', get(URI('http://clients.example.org/')) end + def test_scoped_lambda + scope_called = false + rs.draw do + scope '/foo', :constraints => lambda { |req| scope_called = true } do + get '/', :to => lambda { |env| [200, {}, %w{default}] } + end + end + + assert_equal 'default', get(URI('http://www.example.org/foo/')) + assert scope_called, "scope constraint should be called" + end + + def test_scoped_lambda_with_get_lambda + scope_called = false + inner_called = false + + rs.draw do + scope '/foo', :constraints => lambda { |req| flunk "should not be called" } do + get '/', :constraints => lambda { |req| inner_called = true }, + :to => lambda { |env| [200, {}, %w{default}] } + end + end + + assert_equal 'default', get(URI('http://www.example.org/foo/')) + assert inner_called, "inner constraint should be called" + end + def test_empty_string_match rs.draw do get '/:username', :constraints => { :username => /[^\/]+/ }, |