Assert_redirected_to not recognizing routes

I’m getting a weird error in a call to assert_redirected_to in one of
my functional tests. Here is the test:

def test_signin
admin = users(:adminuser)
post :signin, {:login =>, :realpass => @password}
assert_redirected_to :action => ‘list’ # failure happens on this
assert_equal, session[:user].id

The error is:

  1. Error:
    RuntimeError: The number of parameters does not match the number of
    assert_redirected_to' /opt/local/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/assertions.rb:313:inclean_backtrace’
    assert_redirected_to' ./test/functional/user_controller_test.rb:31:intest_signin’

My signin method redirects the user to ‘/’ if they request the signin
page directly as is happening in this functional test. This route
gets translated to :controller => ‘user’, :action => ‘list’. So the
redirection should be working fine, except that assert_redirected_to
doesn’t seem to know that ‘/’ translates into that controller and
action, so it is getting this error.

If I change my authentication method so that it redirects explicitly
to :controller => ‘user’, action => ‘list’ then this error goes away.
However, this isn’t as flexible of a solution for me, because I would
like to be able to change where ‘/’ points to in one place (my
routes.rb file) and have the entire app adjust accordingly, whereas if
I have the default location explicitly coded in my authentication
method then I have to update it there too.

An ideal solution would probably be something like the opposite of
url_for, which would take a url and return a controller/action/id/etc

Thanks in advance for your help.


This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs