public
Description: Ruby on Rails
Homepage: http://rubyonrails.org
Clone URL: git://github.com/rails/rails.git
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.
NZKoz (author)
Sat Jul 12 02:42:41 -0700 2008
commit  e53f5fe696d692f1985981c34bb311e898fe3c72
tree    9fb8f244d277cc0bc8555a57866955a5d062639f
parent  50b5c6845ed1645cf25613024ef04187385f8dcd
...
63
64
65
 
 
 
 
 
 
66
67
68
69
70
 
 
 
71
72
73
...
63
64
65
66
67
68
69
70
71
72
73
74
 
 
75
76
77
78
79
80
0
@@ -63,11 +63,18 @@ module ActionController
0
         clean_backtrace do
0
           assert_response(:redirect, message)
0
           return true if options == @response.redirected_to
0
+          
0
+          # Support partial arguments for hash redirections
0
+          if options.is_a?(Hash) && @response.redirected_to.is_a?(Hash)
0
+            return true if options.all? {|(key, value)| @response.redirected_to[key] == value}
0
+          end
0
+          
0
           redirected_to_after_normalisation = normalize_argument_to_redirection(@response.redirected_to)
0
           options_after_normalisation       = normalize_argument_to_redirection(options)
0
 
0
-          assert_equal redirected_to_after_normalisation, options_after_normalisation,
0
-                       "Expected response to be a redirect to <#{options_after_normalisation}> but was a redirect to <#{redirected_to_after_normalisation}>"
0
+          if redirected_to_after_normalisation != options_after_normalisation
0
+            flunk "Expected response to be a redirect to <#{options_after_normalisation}> but was a redirect to <#{redirected_to_after_normalisation}>"
0
+          end
0
         end
0
       end
0
 
...
227
228
229
 
 
 
 
 
230
231
232
...
227
228
229
230
231
232
233
234
235
236
237
0
@@ -227,6 +227,11 @@ class RedirectTest < Test::Unit::TestCase
0
     assert_redirected_to Workshop.new(5, true)
0
   end
0
 
0
+  def test_redirect_with_partial_params
0
+    get :module_redirect
0
+    assert_redirected_to :action => 'hello_world'
0
+  end
0
+
0
   def test_redirect_to_nil
0
     assert_raises(ActionController::ActionControllerError) do
0
       get :redirect_to_nil

Comments