Authlogic functional test problem

One of my tests looks like this…

require ‘test_helper’

class ResortsControllerTest < ActionController::TestCase

other tests

def test_destroy_works_when_admin
UserSession.create(users(:admin)) # logs a user in
resort = Resort.first
delete :destroy, :id => resort
assert_redirected_to resorts_url
assert !Resort.exists?(resort.id)
end

end

It works fine and passes when I do this

rake test:functionals TEST=test/functional/resorts_controller_test.rb


But when I do this (run it with my other tests)

rake

It fails, like this

  1. Failure:
    test_destroy_works_when_admin(ResortsControllerTest)
    [/test/functional/resorts_controller_test.rb:104]:
    Expected response to be a redirect to http://test.host/resorts but was
    a redirect to http://test.host/user_sessions/new.

Here’s my test_helper

ENV[“RAILS_ENV”] = “test”
require File.expand_path(File.dirname(FILE) +
“/…/config/environment”)
require ‘test_help’
require “authlogic/test_case” # include at the top of test_helper.rb

class ActiveSupport::TestCase

self.use_transactional_fixtures = true
self.use_instantiated_fixtures = false
fixtures :all

end

Hi bingo bob

A guess is you are losing session somehow? What is the setup method
(if any) for this test? Also would like to see the related controller
code after that

Sijo

Sorry for the copy and paste error, yes the setup should have been
listed, the test code in question is as follows.

require ‘test_helper’

class ResortsControllerTest < ActionController::TestCase

setup :activate_authlogic # run before tests are executed

other tests

def test_destroy_works_when_admin
UserSession.create(users(:admin)) # logs a user in
resort = Resort.first
delete :destroy, :id => resort
assert_redirected_to resorts_url
assert !Resort.exists?(resort.id)
end

end

Any ideas as to what I might be missing here?