Functional Test Fails with before filter in application.rb


#1

Hi There,
I am trying to write my first tests for a role bassed authentication
taken from Rails Recipies. Whenever I add:

assert_redirected_to :action => ‘login’

I get the following error:
NoMethodError: undefined method first' for :user:Symbol /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.1/lib/action_controller/assertions/response_assertions.rb:72:inassert_redirected_to’
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.1/lib/action_controller/assertions/response_assertions.rb:43:in
assert_redirected_to' /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.1/lib/action_controller/assertions.rb:60:inclean_backtrace’
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.1/lib/action_controller/assertions/response_assertions.rb:35:in
assert_redirected_to' test/functional/user_controller_test.rb:24:intest_index_with_user’

The controller I am testing is user_controller.rb
THe check_auth functions are in the application.rb
Would this break it?
Is there some way around this or have i just been staring too long and
missedsomething?
Thanks.

THE TEST:
in user_contorller_test.rb

def test_index_without_user
get :index
assert_response :redirect
assert_redirected_to :action => “login”
assert_equal “Please login”, flash[:notice]
end

in application.rb

before_filter :check_authentication,
:check_authorization,
:except => [:login]

def check_authentication
unless session[:user]
flash[:notice] = “Please login”
redirect_to :controller => :user, :action => :login
return false
end
end