Groups
Groups
Sign in
Groups
Groups
WellRailed
Conversations
About
Send feedback
Help
How do you access the session in a Rails performance test?
114 views
Skip to first unread message
Cyrille
unread,
Oct 19, 2009, 5:51:34 PM
10/19/09
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to WellRailed
Hi guys,
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.
Anybody knows?
Cheers
Cyrille
Andy Newport
unread,
Oct 19, 2009, 9:11:04 PM
10/19/09
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to wellr...@googlegroups.com
I believe PerformanceTest extends IntegrationTest so you should be able to user the open_session(&block) type hook. See the second code example here =>
http://apidock.com/rails/v2.3.4/ActionController/IntegrationTest
Cyrille
unread,
Oct 25, 2009, 8:00:57 PM
10/25/09
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to WellRailed
Hi Andy,
thanks for pointing that out. It works a charm.
Cheers
Cyrille
Reply all
Reply to author
Forward
0 new messages