rack-devel archive mirror (unofficial) https://groups.google.com/group/rack-devel
 help / color / mirror / Atom feed
From: Daniel N <has.sox@gmail.com>
To: rack-devel@googlegroups.com
Subject: Re: Setting session from tests
Date: Tue, 9 Feb 2010 18:46:42 +1100	[thread overview]
Message-ID: <2fff50391002082346j692d4b58r205bc218e78ac52d@mail.gmail.com> (raw)
In-Reply-To: <5b745a22-187a-457c-ab05-9856bd5eaaf4@u26g2000yqm.googlegroups.com>

When using rack test, it maintains a session for you.

In the one test you should post the login deets, and then visit the
URL you want to test.

The session should be sticky between requests from within the same test

hth
Daniel

On Tuesday, February 9, 2010, misza222 <misza222@gmail.com> wrote:
> Hi,
>
> How to set a session from within the tests?
> I am using Rack::Test to test user authorization mechanism. I need to
> make sure that user is redirected to the 'return_to' path which is
> stored in a session.
>
> post '/login', { :'user[email]' => @user.email, :'user[password]' =>
> @user.password }
>
> I tried creating mock request like
>
> Rack::MockRequest.env_for("/login", {:"rack.session" => {:return_to =>
> '/return_to'}})
>
> and appending it as a 3rd parameter to the post method but no luck. It
> was rather hit and miss approach as I don't really know how env is
> organized :/
>
> Can anyone help?
>
> Cheers,
>
> Michal
>

  reply	other threads:[~2010-02-09  7:46 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-09  7:07 Setting session from tests misza222
2010-02-09  7:46 ` Daniel N [this message]
2010-02-09 10:22   ` misza222

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://groups.google.com/group/rack-devel

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2fff50391002082346j692d4b58r205bc218e78ac52d@mail.gmail.com \
    --to=rack-devel@googlegroups.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).