In functional tests get, put etc take a third parameter which allows session
data to be setup. Thus one can say:
  def test_show
    get :show, {:id => @first_id}, { :user_id =>
users(:user_name_from_fixture).id }
    ...

This sets the user_id in the session and allows restful_authentication to
login and setup current_user


2009/1/20 John Small <[email protected]>

>
> I don't need to do functional testing of restful_authentication, but I
> do need to do functional testing of controllers that require
> authentication.
>
> Restful_authentication sets up a session and a current_user but sessions
> aren't available in functional testing. So my integration tests run just
> fine but my functional tests freak out. I have two issues that I need
> advice on.
>
> I can't login and follow the redirect because follow_redirect has been
> taken out of Rails 2.2.2 on the assumption that it belongs in
> integration testing.
>
> 1) I'm accessing @current_user in my views, to test for some property of
> the user and display certain things on the page iff the user has that
> property
>
> 2) I'm also using role_requirement, and when I have require_role set in
> my controllers, nothing works because there's no session, and hence no
> current_user to check the role of.
>
> How should I set things up in this case?
>
> Ta
>
> John Small
> --
> Posted via http://www.ruby-forum.com/.
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to