hi, i did get the login working but i still wonder what it would take
to be able to use, in an integration test, the methods .logged_in?
and .is_member_of methods from the authentication and authorization
plug ins
tia
On May 14, 3:54 pm, Jonathan Linowes
<lino...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> Hi,
>
> # in functional/projects_controller_test.rb
>
> def test_should_show_project_home_page_as_public_exists
> get :show, :id => 2
> assert_redirected_to :controller => ''pages'',
:action => ''show'',
> ''id'' => ''home'', :project_id => 2
> end
>
> SUCCEEDS
>
> def test_should_show_project_as_submitter_no_submission
> login_as(''imasubmitter'')
> get :show, :id => 2
> default_text = "No submissions present for this project."
> assert_select "p#test-for", default_text
> end
>
> SUCCEEDS
>
> ----------------
> # in integration/rr_stories_test.rb
>
> def test_submitter
> new_session do |submitter|
>
submitter.logs_in_as(''imasubmitter'',''test'')
>
> get project_url(2)
> assert_redirected_to :controller => ''pages'',
:action =>
> ''show'', ''id'' =>
''home'', :project_id => 2 # this passes but should
> fail, that is, user is logged in so shouldnt redirect
>
> assert submitter.logged_in? # fails => no method defined
>
> #p = Project.find(2)
> #assert submitter.has_role( ''submitter'', p)
>
> end
> end
>
> # QUESTIONS:
> You can see the projects controller tests pass. Anonymous user is
> redirected. Logged in one lands on page.
>
> In integration test however,
> 1. user does not seem to get logged in, because controller is
> redirecting. Why isnt he logged in?
> 2. how can i assert whether the login worked? (testing the test here,
> i guess)
> once 1 and 2 are working, then
> 3. how can i access methods defined by the authorization plugin for a
> given user?
>
> thanks for any help or suggestions
--~--~---------~--~----~------------~-------~--~----~
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
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---