diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2006-02-27 05:14:57 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2006-02-27 05:14:57 +0000 |
commit | 91247b61672c3d136682870558e5068f4c7195f0 (patch) | |
tree | d5abf90c733e952af64795e5666783924ca9c037 /activerecord/lib | |
parent | adccb319e27190a3a90d321db1141a057aec1d38 (diff) | |
download | rails-91247b61672c3d136682870558e5068f4c7195f0.tar.gz rails-91247b61672c3d136682870558e5068f4c7195f0.tar.bz2 rails-91247b61672c3d136682870558e5068f4c7195f0.zip |
Added that fixtures to placed in subdirectories of the main fixture files are also loaded (closes #3937) [dblack@wobblini.net]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3683 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/lib')
-rwxr-xr-x | activerecord/lib/active_record/fixtures.rb | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/fixtures.rb b/activerecord/lib/active_record/fixtures.rb index 3d2fa3ac71..3254781764 100755 --- a/activerecord/lib/active_record/fixtures.rb +++ b/activerecord/lib/active_record/fixtures.rb @@ -286,11 +286,18 @@ class Fixtures < YAML::Omap end private + def read_fixture_files if File.file?(yaml_file_path) # YAML fixtures begin - if yaml = YAML::load(erb_render(IO.read(yaml_file_path))) + yaml_string = "" + Dir["#{@fixture_path}/**/*"].select {|f| test(?f,f) }.each do |subfixture_path| + yaml_string << IO.read(subfixture_path) + end + yaml_string << IO.read(yaml_file_path) + + if yaml = YAML::load(erb_render(yaml_string)) yaml = yaml.value if yaml.respond_to?(:type_id) and yaml.respond_to?(:value) yaml.each do |name, data| self[name] = Fixture.new(data, @class_name) |