# Integration tests failing with restful\_authentication

**URL:** <https://www.ruby-forum.com/t/integration-tests-failing-with-restful-authentication/194751>\
**Category:** Rails\
**Created:** [September 9, 2010, 11:18pm UTC](https://www.ruby-forum.com/t/integration-tests-failing-with-restful-authentication/194751 "2010-09-09T23:18:48Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![smithy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/a4c791/32.png) [@smithy](https://www.ruby-forum.com/u/smithy)\
**Post date:** [September 9, 2010, 11:18pm UTC](https://www.ruby-forum.com/t/integration-tests-failing-with-restful-authentication/194751/1 "2010-09-09T23:18:48Z")

</div>

I recently upgraded to Rails 2.3.8 from 2.1.0 (not sure if that has  
anything to do with it though), and my integration tests are no longer  
able to do anything requiring the user to be logged in. The tests can  
log in successfully, but when another request is made, the user is no  
longer recognized as logged in.

When I inspect the session just after logging in, I see this:  
{:user\_id=\>4,  
“flash”=\>{:notice=\>“Logged in successfully”},  
:session\_id=\>“76df7358fb3dd5f5ff97f15e4a3c652a”}

When I do another request, eg get “/home”, the session contains only  
this:  
{:return\_to=\>"/home",  
:session\_id=\>“76df7358fb3dd5f5ff97f15e4a3c652a”}

This problem only exists within the tests… when I manually visit the  
site, everything works perfectly. I have upgraded restful\_authentication  
plugin, I have gone through the whole process with the debugger, I have  
tried everything I can think of to find the problem, but I’m totally  
stumped. What could be causing this?

Thanks!  
Jack

---

<div class="post-metadata">

**Author:** ![smithy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/a4c791/32.png) [@smithy](https://www.ruby-forum.com/u/smithy)\
**Post date:** [September 9, 2010, 11:27pm UTC](https://www.ruby-forum.com/t/integration-tests-failing-with-restful-authentication/194751/2 "2010-09-09T23:27:25Z")

</div>

Jack Senechal wrote:

> I recently upgraded to Rails 2.3.8 from 2.1.0 (not sure if that has  
> anything to do with it though), and my integration tests are no longer  
> able to do anything requiring the user to be logged in.  
> […]

> I have upgraded restful\_authentication  
> plugin, I have gone through the whole process with the debugger, I have  
> tried everything I can think of to find the problem, but I’m totally  
> stumped. What could be causing this?

I’m not absolutely sure, but IMHO you should give some serious thought  
to removing both restful\_authentication and integration tests.  
restful\_authentication is (as you’ve discovered) hard to test, due in  
part to relying on unmaintainable generated code thrown right into your  
User model. I recommend replacing it with Authlogic, which is better  
designed, more modular, and easier to test.

Likewise, Cucumber can (and should) take the place of integration tests;  
you’ll have fewer headaches.

> Thanks!  
> Jack

## Best,

Marnen Laibow-koser  
[http://www.marnen.org](http://www.marnen.org)  
removed\_email\_address@domain.invalid
