Permalink
Browse files

Move fixtures settings from AR::TestCase to railties test_help

  • Loading branch information...
1 parent a0e7b99 commit b17eb65d00242ae10ac9ed97ef22d88fdd710533 @jeremy jeremy committed Nov 12, 2008
Showing with 15 additions and 19 deletions.
  1. +1 −11 activerecord/lib/active_record/test_case.rb
  2. +14 −8 railties/lib/test_help.rb
View
12 activerecord/lib/active_record/test_case.rb
@@ -1,18 +1,8 @@
require "active_support/test_case"
require "active_record/fixtures"
-module ActiveRecord
+module ActiveRecord
class TestCase < ActiveSupport::TestCase #:nodoc:
- include TestFixtures
-
- self.fixture_path = FIXTURES_ROOT
- self.use_instantiated_fixtures = false
- self.use_transactional_fixtures = true
-
- def create_fixtures(*table_names, &block)
- Fixtures.create_fixtures(FIXTURES_ROOT, table_names, {}, &block)
- end
-
def assert_date_from_db(expected, actual, message = nil)
# SQL Server doesn't have a separate column type just for dates,
# so the time is in the string and incorrectly formatted
View
22 railties/lib/test_help.rb
@@ -7,16 +7,22 @@
require 'action_controller/integration'
require 'action_mailer/test_case' if defined?(ActionMailer)
-require 'active_record/fixtures'
-class ActiveSupport::TestCase
- include ActiveRecord::TestFixtures
-end
+if defined?(ActiveRecord)
+ require 'active_record/test_case'
+ require 'active_record/fixtures'
+
+ class ActiveSupport::TestCase
+ include ActiveRecord::TestFixtures
+ self.fixture_path = "#{RAILS_ROOT}/test/fixtures/"
+ self.use_instantiated_fixtures = false
+ self.use_transactional_fixtures = true
+ end
-ActiveSupport::TestCase.fixture_path = "#{RAILS_ROOT}/test/fixtures/"
-ActionController::IntegrationTest.fixture_path = ActiveSupport::TestCase.fixture_path
+ ActionController::IntegrationTest.fixture_path = ActiveSupport::TestCase.fixture_path
-def create_fixtures(*table_names)
- Fixtures.create_fixtures(ActiveSupport::TestCase.fixture_path, table_names)
+ def create_fixtures(*table_names, &block)
+ Fixtures.create_fixtures(ActiveSupport::TestCase.fixture_path, table_names, {}, &block)
@alexeymuranov
alexeymuranov May 12, 2012

@jeremy, is it ok to use Fixtures here without full namespace (ActiveRecord::Fixtures)?

I am trying to rename Fixtures to FixtureSet, i could do some other changes too.

Also this code looks very similar to https://github.com/rails/rails/blob/master/activerecord/test/cases/helper.rb#L83, i wonder if it cannot be somehow put in one place...

+ end
end
begin

0 comments on commit b17eb65

Please sign in to comment.