1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Fix regression on assert_redirected_to.

`assert_redirected_to` would fail if there is no controller set on
a `ActionDispatch::IntegrationTest`, as _compute_redirect_to_location
would be called on the controller to build the url.

This regression was introduced after 1dacfbabf3.

[fixes #14691]
This commit is contained in:
Arthur Neves 2014-05-13 00:03:38 -04:00
parent 84908bbde9
commit 7ec665303d
No known key found for this signature in database
GPG key ID: 04A390FB1E433E17
2 changed files with 13 additions and 1 deletions

View file

@ -73,7 +73,13 @@ module ActionDispatch
if Regexp === fragment
fragment
else
@controller._compute_redirect_to_location(fragment)
handle = @controller || Class.new(ActionController::Metal) do
include ActionController::Redirecting
def initialize(request)
@_request = request
end
end.new(@request)
handle._compute_redirect_to_location(fragment)
end
end
end

View file

@ -374,6 +374,10 @@ class IntegrationProcessTest < ActionDispatch::IntegrationTest
follow_redirect!
assert_response :success
assert_equal "/get", path
get '/moved'
assert_response :redirect
assert_redirected_to '/method'
end
end
@ -511,6 +515,8 @@ class IntegrationProcessTest < ActionDispatch::IntegrationTest
end
set.draw do
get 'moved' => redirect('/method')
match ':action', :to => controller, :via => [:get, :post], :as => :action
get 'get/:action', :to => controller, :as => :get_action
end