Permalink
Browse files

2-0-stable: Fix Fixtures for ActionController tests with fixtures. Cl…

…oses #11162 [menno.sman]

git-svn-id: http://svn-commit.rubyonrails.org/rails/branches/2-0-stable@8910 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent 9d03813 commit 6a386ea70632aed4aed3e4d17fa208f8a4d2bc42 @NZKoz NZKoz committed Feb 20, 2008
Showing with 25 additions and 0 deletions.
  1. +1 −0 actionpack/lib/action_controller/test_case.rb
  2. +24 −0 actionpack/test/activerecord/fixtures_test.rb
@@ -62,6 +62,7 @@ def self.method_added(method)
unless method_defined?(:setup_without_controller)
alias_method :setup_without_controller, :setup
define_method(:setup) do
+ setup_with_fixtures if respond_to?(:setup_with_fixtures)
setup_with_controller
setup_without_controller
end
@@ -0,0 +1,24 @@
+require File.dirname(__FILE__) + '/../active_record_unit'
+require "action_controller/test_case"
+
+class ActionController::TestCase
+ self.fixture_path = File.dirname(__FILE__) + '/../fixtures'
+ self.use_transactional_fixtures = false
+end
+
+class DeveloperController < ActionController::Base
+end
+
+class DeveloperControllerTest < ActionController::TestCase
+ fixtures :developers
+
+ def setup
+ @david = developers(:david)
+ end
+
+ def test_should_have_loaded_fixtures
+ assert_kind_of(Developer, @david)
+ assert_kind_of(Developer, developers(:jamis))
+ assert_equal(@developers.size, Developer.count)
+ end
+end

0 comments on commit 6a386ea

Please sign in to comment.