Setting session user into functional tests

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

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