This method is deprecated or moved on the latest stable version.
The last existing version (v2.3.8) is shown here.
assert_redirected_to(options = {}, message=nil)
public
Assert that the redirection options passed in match those of the redirect
called in the latest action. This match can be partial, such that assert_redirected_to(:controller
=> "weblog") will also match the redirection of
redirect_to(:controller => "weblog", :action =>
"show") and so on.
Examples
# assert that the redirection was to the "index" action on the WeblogControllerassert_redirected_to:controller=>"weblog",:action=>"index"# assert that the redirection was to the named route login_urlassert_redirected_tologin_url# assert that the redirection was to the url for @customerassert_redirected_to@customer
# File actionpack/lib/action_controller/assertions/response_assertions.rb, line 59
def assert_redirected_to(options = {}, message=nil)
clean_backtrace do
assert_response(:redirect, message)
return true if options == @response.redirected_to
# Support partial arguments for hash redirections
if options.is_a?(Hash) && @response.redirected_to.is_a?(Hash)
if options.all? {|(key, value)| @response.redirected_to[key] == value}
callstack = caller.dup
callstack.slice!(0, 2)
::ActiveSupport::Deprecation.warn("Using assert_redirected_to with partial hash arguments is deprecated. Specify the full set arguments instead", callstack)
return true
end
end
redirected_to_after_normalisation = normalize_argument_to_redirection(@response.redirected_to)
options_after_normalisation = normalize_argument_to_redirection(options)
if redirected_to_after_normalisation != options_after_normalisation
flunk "Expected response to be a redirect to <#{options_after_normalisation}> but was a redirect to <#{redirected_to_after_normalisation}>"
end
end
end