Forum: Ruby on Rails Functional Test Fails with before filter in application.rb

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Dinshaw G. (Guest)
on 2007-01-21 07:05
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
    test/functional/user_controller_test.rb:24:in `test_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

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]

in application.rb

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

  def check_authentication
    unless session[:user]
      flash[:notice] = "Please login"
      redirect_to :controller => :user, :action => :login
      return false
This topic is locked and can not be replied to.