NewForge (7) [Avatar] Offline
#1
Changeset 8022 has placed a 'setup' method within /action_controller/test_case.rb. Also, the scaffolded Rails 2.0 ControllerTest now appears to access its fixtures via a call to 'tests' rather than 'fixtures'.

To get the functional tests (locations_controller, projects_controller and tasks_controller) to pass, I took this approach:

class LocationsControllerTest < ActionController::TestCase
tests LocationsController
fixtures :users

def setup
super
login_as :ludwig
end
...
dfwgator (6) [Avatar] Offline
#2
Re: Rails 2.0 functional test setup (p.174)
Thank You For that, I racked my brain for a couple hours trying to figure out why the tests were failing. That cleared it right up!
peterarmstrong (94) [Avatar] Offline
#3
Re: Rails 2.0 functional test setup (p.174)
Heh, I racked my brain too -- I think that you can just omit the "tests" line altogether...

require File.dirname(__FILE__) + '/../test_helper'
require 'locations_controller'

# Re-raise errors caught by the controller.
class LocationsController; def rescue_action(e) raise e end; end

class LocationsControllerTest < Test::Unit::TestCase
fixtures :users

def setup
@controller = LocationsController.new
@request = ActionController::TestRequest.new
@response = ActionController::TestResponse.new
login_as :ludwig
end
...
peterarmstrong (94) [Avatar] Offline
#4
Re: Rails 2.0 functional test setup (p.174)
(The above was the way that I updated the tests to fix the errors -- as you show, there may be a better way to do it--looking into it...)