I am using restful authentication. So, some controllers requires a session with a user logged in. Now, I am trying to write functional tests for those controllers. I wanna set a session user (in ''setup'' for example) and than test assertions supposing that a user is logged in. How can I do that? Regards, -- Bruno Guimarães Sousa www.brunosousa.co.nr COINF-CEFET-BA Ciência da Computação UFBA Registered Linux user #465914 --~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Craig White
2008-Jun-04 19:51 UTC
Re: ****[Rails] Setting session user into functional tests
On Wed, 2008-06-04 at 16:44 -0300, Bruno Guimarães Sousa wrote:> I am using restful authentication. > So, some controllers requires a session with a user logged in. > Now, I am trying to write functional tests for those controllers. I > wanna set a session user (in ''setup'' for example) and than test > assertions supposing that a user is logged in. How can I do that?---- here''s how I did it... added to test/test_helper.rb def login_with_administrator @authuser = User.find 1 @request.session[:user_id] = @authuser.id @request.session[:user_name] = @authuser.name end than in any controller_test.rb I simply call ''login_with_administrator'' Change session variables as necessary Craig --~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---