Forum: Ruby on Rails functional vs integration tests with restful_auth

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Cd804cfeeea508f6bf2f5487c9ef4aed?d=identicon&s=25 Jonathan Linowes (Guest)
on 2007-05-14 21:58
(Received via mailing list)

# 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


   def test_should_show_project_as_submitter_no_submission
     get :show, :id => 2
     default_text = "No submissions present for this project."
     assert_select "p#test-for", default_text


# in integration/rr_stories_test.rb

   def test_submitter
     new_session do |submitter|

       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)


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
Cd804cfeeea508f6bf2f5487c9ef4aed?d=identicon&s=25 linoj (Guest)
on 2007-05-15 08:33
(Received via mailing list)
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

This topic is locked and can not be replied to.