Permalink
Browse files

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
  • Loading branch information...
dhh committed Dec 14, 2004
1 parent 68d1056 commit bc1aa7d9fda8bf9765f7ae91d5236aedb0cdd386
@@ -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
@@ -1,4 +1,5 @@
$:.unshift(File.dirname(__FILE__) + '/../lib')
+# $:.unshift(File.dirname(__FILE__) + '/fixtures')
require 'test/unit'
require 'active_record'
@@ -1,8 +1,4 @@
require 'abstract_unit'
-require 'fixtures/topic'
-require 'fixtures/reply'
-require 'fixtures/developer'
-
class ValidationsTest < Test::Unit::TestCase
fixtures :topics, :developers

0 comments on commit bc1aa7d

Please sign in to comment.