diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2004-12-14 18:01:28 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2004-12-14 18:01:28 +0000 |
commit | bc1aa7d9fda8bf9765f7ae91d5236aedb0cdd386 (patch) | |
tree | 6752027ff6af4b01333a461d7aaaa1dff5b9b007 | |
parent | 68d1056587d96cf3a413253cde126f2522d36c64 (diff) | |
download | rails-bc1aa7d9fda8bf9765f7ae91d5236aedb0cdd386.tar.gz rails-bc1aa7d9fda8bf9765f7ae91d5236aedb0cdd386.tar.bz2 rails-bc1aa7d9fda8bf9765f7ae91d5236aedb0cdd386.zip |
fixtures :models will now also attempt to include the model.rb file
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@153 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
-rwxr-xr-x | activerecord/lib/active_record/fixtures.rb | 11 | ||||
-rwxr-xr-x | activerecord/test/abstract_unit.rb | 1 | ||||
-rwxr-xr-x | activerecord/test/validations_test.rb | 4 |
3 files changed, 12 insertions, 4 deletions
diff --git a/activerecord/lib/active_record/fixtures.rb b/activerecord/lib/active_record/fixtures.rb index 320b0dbe78..8447a33c7d 100755 --- a/activerecord/lib/active_record/fixtures.rb +++ b/activerecord/lib/active_record/fixtures.rb @@ -301,9 +301,20 @@ class Test::Unit::TestCase #:nodoc: cattr_accessor :fixture_table_names def self.fixtures(*table_names) + require_fixture_classes(table_names) write_inheritable_attribute("fixture_table_names", table_names) end + def self.require_fixture_classes(table_names) + table_names.each do |table_name| + begin + require(Inflector.singularize(table_name.to_s)) + rescue LoadError + # Let's hope the developer is included it himself + end + end + end + def setup instantiate_fixtures(*fixture_table_names) if fixture_table_names end diff --git a/activerecord/test/abstract_unit.rb b/activerecord/test/abstract_unit.rb index a4a1b55cb2..293f3ba6b3 100755 --- a/activerecord/test/abstract_unit.rb +++ b/activerecord/test/abstract_unit.rb @@ -1,4 +1,5 @@ $:.unshift(File.dirname(__FILE__) + '/../lib') +# $:.unshift(File.dirname(__FILE__) + '/fixtures') require 'test/unit' require 'active_record' diff --git a/activerecord/test/validations_test.rb b/activerecord/test/validations_test.rb index b4b0997c94..e104573c25 100755 --- a/activerecord/test/validations_test.rb +++ b/activerecord/test/validations_test.rb @@ -1,8 +1,4 @@ require 'abstract_unit' -require 'fixtures/topic' -require 'fixtures/reply' -require 'fixtures/developer' - class ValidationsTest < Test::Unit::TestCase fixtures :topics, :developers |