#121 ✓moved_to_github
David North

UserSession not maintained for Integration tests

Reported by David North | June 12th, 2009 @ 07:49 AM

I'm trying to write integration tests for screens that require a logged in user. I'm using Webrat too.
I've added the following to test_helper

require 'authlogic/test_case'

And to my integration test:

  def setup 
    activate_authlogic
    UserSession.create! Factory.build(:user)
  end

The problem is that the session isn't maintained and my tests end up back at the login screen. I've confirmed that UserSession is created by checking the following in my tests:
UserSession.find (shows a valid UserSession instance)
UserSession.find.record (shows a valid User instance)
I've traced this back to current_user_session which is returning nil in application controller causing require_user to fail. In application_controller UserSession.find gives nil so somehow the session object is created fine in my tests but is lost in the controller.

My test just contains the following for now:

    visit '/clients'
    assert_contain 'Clients'

I'm using:
Authlogic 2.0.13
Rails 2.3.2
Webrat 0.4.4

Many thanks
David

Comments and changes to this ticket

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

Object based authentication solution that handles all of the non sense for you. It's as easy as ActiveRecord is with a database.

People watching this ticket

Pages