diff options
author | Michael Koziarski <michael@koziarski.com> | 2008-07-12 11:42:41 +0200 |
---|---|---|
committer | Michael Koziarski <michael@koziarski.com> | 2008-07-12 11:42:41 +0200 |
commit | e53f5fe696d692f1985981c34bb311e898fe3c72 (patch) | |
tree | 9fb8f244d277cc0bc8555a57866955a5d062639f /actionpack/lib/action_controller/assertions | |
parent | 50b5c6845ed1645cf25613024ef04187385f8dcd (diff) | |
download | rails-e53f5fe696d692f1985981c34bb311e898fe3c72.tar.gz rails-e53f5fe696d692f1985981c34bb311e898fe3c72.tar.bz2 rails-e53f5fe696d692f1985981c34bb311e898fe3c72.zip |
Restore support for partial matches in assert_redirected_to
If both the actual redirection and the asserted redirection are hashes, succeed if the asserted redirection is a strict subset of the actual redirection.
Diffstat (limited to 'actionpack/lib/action_controller/assertions')
-rw-r--r-- | actionpack/lib/action_controller/assertions/response_assertions.rb | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/actionpack/lib/action_controller/assertions/response_assertions.rb b/actionpack/lib/action_controller/assertions/response_assertions.rb index 3ecaee641f..64aaf6211f 100644 --- a/actionpack/lib/action_controller/assertions/response_assertions.rb +++ b/actionpack/lib/action_controller/assertions/response_assertions.rb @@ -63,11 +63,18 @@ module ActionController 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) + return true if options.all? {|(key, value)| @response.redirected_to[key] == value} + end + redirected_to_after_normalisation = normalize_argument_to_redirection(@response.redirected_to) options_after_normalisation = normalize_argument_to_redirection(options) - assert_equal redirected_to_after_normalisation, options_after_normalisation, - "Expected response to be a redirect to <#{options_after_normalisation}> but was a redirect to <#{redirected_to_after_normalisation}>" + 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 |