On Wed, Mar 5, 2008 at 4:30 PM, Bastien <[EMAIL PROTECTED]> wrote:
> I've just begin using rspec stories, and i m encountering some
>  problems. In my application i have different subdomains in which
>  specific users can log in, for example an admin will go to
>  admin.myapp.com/authenticate/login, and an user belonging to a
>  specific company will log in company.myapp.com/authenticate/login, and
>  of course both have a different login process.
>
>  To perform some actions the user has to be logged in, and this is
>  where the problem comes, how to test these actions ?
>
>  - Is there a way to set a user as logged in ? (that would definitely
>  be very convenient)
>
>  So far I have tried to do the following :
>
>  post "/authenticate/login",
>    {:login => user_email,
>    :password => password }
>
>  but the problem is that it doesn't use the correct subdomain and the
>  login, as expected in that case, fails, so how to define the correct
>  subdomain ?

RailsStory wraps ActionController::IntegrationTest, which delegates
calls to ActionController::Integration::Session. Check out the rdoc
(http://api.rubyonrails.com/classes/ActionController/Integration/Session.html)
and you'll see a host! method
(http://api.rubyonrails.com/classes/ActionController/Integration/Session.html#M000237).
So ...

host! "whatever subdomain"
post "/authenticate/login", ....

Cheers,
David

>
>  Thank you in advance for your help.
>  _______________________________________________
>  rspec-users mailing list
>  [email protected]
>  http://rubyforge.org/mailman/listinfo/rspec-users
>
_______________________________________________
rspec-users mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/rspec-users

Reply via email to