diff options
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/lib/action_dispatch/routing/redirection.rb | 3 | ||||
-rw-r--r-- | actionpack/test/dispatch/routing_test.rb | 15 |
2 files changed, 17 insertions, 1 deletions
diff --git a/actionpack/lib/action_dispatch/routing/redirection.rb b/actionpack/lib/action_dispatch/routing/redirection.rb index 330400e139..4d98f20826 100644 --- a/actionpack/lib/action_dispatch/routing/redirection.rb +++ b/actionpack/lib/action_dispatch/routing/redirection.rb @@ -102,7 +102,8 @@ module ActionDispatch if block && block.respond_to?(:arity) && block.arity < 2 msg = "redirect blocks with arity of #{block.arity} are deprecated. Your block must take 2 parameters: the environment, and a request object" ActiveSupport::Deprecation.warn msg - block = lambda { |params, _| block.call(params) } + deprecated_block = block + block = lambda { |params, _| deprecated_block.call(params) } end raise ArgumentError, "redirection argument not supported" unless block diff --git a/actionpack/test/dispatch/routing_test.rb b/actionpack/test/dispatch/routing_test.rb index b96987410f..50b959cc39 100644 --- a/actionpack/test/dispatch/routing_test.rb +++ b/actionpack/test/dispatch/routing_test.rb @@ -694,6 +694,21 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest def test_redirect_proc with_test_routes do get '/account/proc/person' + + verify_redirect 'http://www.example.com/people' + end + end + + def test_redirect_deprecated_proc + assert_deprecated do + self.class.stub_controllers do |routes| + routes.draw { match 'account/deprecated_proc/:name', :to => redirect {|params| "/#{params[:name].pluralize}" } } + end + end + + with_test_routes do + get '/account/proc/person' + verify_redirect 'http://www.example.com/people' end end |