Dinshaw Gobhai
2007-Jan-21 05:05 UTC
Functional Test Fails with before filter in application.rb
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:in `assert_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:in `clean_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: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 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 -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---