Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Improve the error message for assert_redirected_to. Closes #7337 [mik…

…ong, sandofsky]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7934 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
commit 5cb6a9aabdd2d74b7c8b52828f6b4797714ce78b 1 parent cfe36d1
@jeremy jeremy authored
View
5 actionpack/lib/action_controller/assertions/response_assertions.rb
@@ -79,9 +79,8 @@ def assert_redirected_to(options = {}, message=nil)
url[key] = value
end
- @response_diff = url[:expected].diff(url[:actual]) if url[:actual]
- msg = build_message(message, "response is not a redirection to all of the options supplied (redirection is <?>), difference: <?>",
- url[:actual], @response_diff)
+ @response_diff = url[:actual].diff(url[:expected]) if url[:actual]
+ msg = build_message(message, "expected a redirect to <?>, found one to <?>, a difference of <?> ", url[:expected], url[:actual], @response_diff)
assert_block(msg) do
url[:expected].keys.all? do |k|
View
4 actionpack/test/controller/redirect_test.rb
@@ -162,11 +162,11 @@ def test_redirect_error_with_pretty_diff
begin
assert_redirected_to :action => "other_host", :only_path => true
rescue Test::Unit::AssertionFailedError => err
- redirection_msg, diff_msg = err.message.scan(/<\{[^\}]+\}>/).collect { |s| s[2..-3] }
+ expected_msg, redirection_msg, diff_msg = err.message.scan(/<\{[^\}]+\}>/).collect { |s| s[2..-3] }
assert_match %r("only_path"=>false), redirection_msg
assert_match %r("host"=>"other.test.host"), redirection_msg
assert_match %r("action"=>"other_host"), redirection_msg
- assert_match %r("only_path"=>true), diff_msg
+ assert_match %r("only_path"=>false), diff_msg
assert_match %r("host"=>"other.test.host"), diff_msg
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.