diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2014-08-29 14:54:08 -0700 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2014-08-29 14:54:08 -0700 |
commit | 7475b43cdbbbf7456e798210cb97ef20f2225166 (patch) | |
tree | 04ae517943ccc476ca0a8b9b3bdbb21949a558c1 /actionpack/test/dispatch/routing_test.rb | |
parent | 6a23bf0f4c33151e0cec0648e271dc6f5ab3f686 (diff) | |
parent | 4445478df311a74797d8dc4945c40662f9c1442a (diff) | |
download | rails-7475b43cdbbbf7456e798210cb97ef20f2225166.tar.gz rails-7475b43cdbbbf7456e798210cb97ef20f2225166.tar.bz2 rails-7475b43cdbbbf7456e798210cb97ef20f2225166.zip |
Merge branch 'master' of github.com:rails/rails
Diffstat (limited to 'actionpack/test/dispatch/routing_test.rb')
-rw-r--r-- | actionpack/test/dispatch/routing_test.rb | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/actionpack/test/dispatch/routing_test.rb b/actionpack/test/dispatch/routing_test.rb index b8e20c52a0..d141210ad9 100644 --- a/actionpack/test/dispatch/routing_test.rb +++ b/actionpack/test/dispatch/routing_test.rb @@ -14,6 +14,12 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest end end + class GrumpyRestrictor + def self.matches?(request) + false + end + end + class YoutubeFavoritesRedirector def self.call(params, request) "http://www.youtube.com/watch?v=#{params[:youtube_id]}" @@ -89,6 +95,24 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest verify_redirect 'http://www.example.com/private/index' end + def test_redirect_with_failing_constraint + draw do + get 'hi', to: redirect("/foo"), constraints: ::TestRoutingMapper::GrumpyRestrictor + end + + get '/hi' + assert_equal 404, status + end + + def test_redirect_with_passing_constraint + draw do + get 'hi', to: redirect("/foo"), constraints: ->(req) { true } + end + + get '/hi' + assert_equal 301, status + end + def test_namespace_with_controller_segment assert_raise(ArgumentError) do draw do |