I am writing some performance tests and I want the user to be logged in:
class CompaniesTest < ActionController::PerformanceTest
fixtures :all
def setup
login_as(:cyrille)
end
def test_homepage
get '/'
end
end
The problem is: how should I implement login_as?
I tried:
private
def login_as(user)
@request = ActionController::TestRequest.new
@request.session[:user] = user ? users(user).id : nil
end
But the session[:user] is empty when it gets checked by the application.
Obviously there must be a session object created by the PerformanceTest, but I can't see how I am supposed to access it.