Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
How do you access the session in a Rails performance test?
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  3 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Cyrille  
View profile  
 More options Oct 19, 5:51 pm
From: Cyrille <cbonne...@gmail.com>
Date: Mon, 19 Oct 2009 14:51:34 -0700 (PDT)
Local: Mon, Oct 19 2009 5:51 pm
Subject: How do you access the session in a Rails performance test?
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


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Andy Newport  
View profile  
 More options Oct 19, 9:11 pm
From: Andy Newport <newporta...@gmail.com>
Date: Tue, 20 Oct 2009 14:11:04 +1300
Local: Mon, Oct 19 2009 9:11 pm
Subject: Re: [WellRailed] How do you access the session in a Rails performance test?

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


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Cyrille  
View profile  
 More options Oct 25, 8:00 pm
From: Cyrille <cbonne...@gmail.com>
Date: Sun, 25 Oct 2009 17:00:57 -0700 (PDT)
Local: Sun, Oct 25 2009 8:00 pm
Subject: Re: How do you access the session in a Rails performance test?
Hi Andy,

thanks for pointing that out. It works a charm.

Cheers

Cyrille

On Oct 20, 2:11 pm, Andy Newport <newporta...@gmail.com> wrote:


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google