Strange assertion problem

Hello,

I'm trying to write some functionnal tests for one of my controllers and I've got a strange problem. In my test code I'm doing the following :

   def test_index_user_not_login
     get :index
     assert_response :redirect
     assert_redirected_to :controller => "user", :action => "login"
   end

and when I launch the test, I've got this error :

  1) Failure:
test_index_user_not_login(Admin::ConfigurationControllerTest) [./test/functional/admin/configuration_controller_test.rb:20]:
response is not a redirection to all of the options supplied (redirection is <{:action=>"login", :controller=>"user"}>), difference: <{}>

So if I understand, the testing tasks tells me that my redirection isn't correct (I test it by hand and it works well) and that's the difference is {}, so nothing different ... Odd.

If I change:

assert_redirected_to :controller => "user", :action => "login"

to:

assert_redirected_to :action => "login"

it works ...

Any clue ?

What is the actual redirect_to call? I’ve found that Rails can be quite picky with functional tests and redirect checking, so make sure that the url_options are the exact same in both places.

Jason

The redirect_to is : redirect_to :controller => 'user', :action => 'login'

It's the one found in authenticated_system.rb that's ship with Acts_as_authenticated ...

I'm using a before_filter with the login_required method to ensure that the user is login to access an admin page.

i has this exact problem and my redirect_to did NOT have the
:controller part. Are you sure yours does?

in my Post controller i can call
redirect_to :action => 'list'

if I then test for the following it will fail.
assert_redirected_to :controller => 'post', :action => "list"

Double check that your not doing this.

Mine does yes. I'm pretty sure it's a Rails bug because if I do this:

assert_redirected_to @controller.url_for(:controller => 'user', :action => 'login')

it works like a charm ...

So I'm wondering why assert_redirected_to :controller => 'user', :action => 'login' doesn't work ...

I'm going to check if there's a bug report for that and if it doesn't I'm going to open one.