Integration tests failing with restful_authentication

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

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,