diff options
author | Agis- <corestudiosinc@gmail.com> | 2014-08-22 16:52:48 +0300 |
---|---|---|
committer | Agis- <corestudiosinc@gmail.com> | 2014-08-25 00:18:25 +0300 |
commit | d78f3f0ec33d57e78249d5b96f38401a1c239410 (patch) | |
tree | c104b4ea6c2bc8522290ea4970b4ebbe3b0421aa /actionpack/test | |
parent | 53cc3ab46bc0822a804b69e4ba05892e69982cac (diff) | |
download | rails-d78f3f0ec33d57e78249d5b96f38401a1c239410.tar.gz rails-d78f3f0ec33d57e78249d5b96f38401a1c239410.tar.bz2 rails-d78f3f0ec33d57e78249d5b96f38401a1c239410.zip |
Don't ignore constraints in redirect routes
https://github.com/rails/rails/commit/402c2af55053c2f29319091ad21fd6fa6b90ee89
introduced a regression that caused any constraints added to redirect routes
to be ignored.
Fixes #16605
Diffstat (limited to 'actionpack/test')
-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 |