# Functional vs integration tests with restful\_auth

**URL:** <https://www.ruby-forum.com/t/functional-vs-integration-tests-with-restful-auth/104162>\
**Category:** Rails\
**Created:** [May 14, 2007, 9:58pm UTC](https://www.ruby-forum.com/t/functional-vs-integration-tests-with-restful-auth/104162 "2007-05-14T21:58:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![johanatan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/8491ac/32.png) [@johanatan](https://www.ruby-forum.com/u/johanatan)\
**Post date:** [May 14, 2007, 9:58pm UTC](https://www.ruby-forum.com/t/functional-vs-integration-tests-with-restful-auth/104162/1 "2007-05-14T21:58:00Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![johanatan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/8491ac/32.png) [@johanatan](https://www.ruby-forum.com/u/johanatan)\
**Post date:** [May 15, 2007, 8:33am UTC](https://www.ruby-forum.com/t/functional-vs-integration-tests-with-restful-auth/104162/2 "2007-05-15T08:33:08Z")

</div>

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
