Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #11767 from kassio/master-load-fixtures-from-linke…

…d-folder

Load fixtures from linked folders[master]
  • Loading branch information...
commit 06198ed7ad822145e24d9aa964aba97bdb0f8b39 1 parent 7bfbd04
@rafaelfranca rafaelfranca authored
View
4 activerecord/CHANGELOG.md
@@ -1,5 +1,9 @@
## unreleased ##
+* Load fixtures from linked folders.
+
+ *Kassio Borges*
+
* Create a directory for sqlite3 file if not present on the system.
*Richard Schneeman*
View
4 activerecord/lib/active_record/fixtures.rb
@@ -639,7 +639,7 @@ def column_names
end
def read_fixture_files
- yaml_files = Dir["#{@path}/**/*.yml"].select { |f|
+ yaml_files = Dir["#{@path}/{**,*}/*.yml"].select { |f|
::File.file?(f)
} + [yaml_file_path]
@@ -758,7 +758,7 @@ def set_fixture_class(class_names = {})
def fixtures(*fixture_set_names)
if fixture_set_names.first == :all
- fixture_set_names = Dir["#{fixture_path}/**/*.{yml}"]
+ fixture_set_names = Dir["#{fixture_path}/{**,*}/*.{yml}"]
fixture_set_names.map! { |f| f[(fixture_path.to_s.size + 1)..-5] }
else
fixture_set_names = fixture_set_names.flatten.map { |n| n.to_s }
View
4 activerecord/test/cases/fixtures_test.rb
@@ -572,7 +572,7 @@ class LoadAllFixturesTest < ActiveRecord::TestCase
fixtures :all
def test_all_there
- assert_equal %w(developers people tasks), fixture_table_names.sort
+ assert_equal %w(admin/accounts admin/users developers people tasks), fixture_table_names.sort
end
end
@@ -581,7 +581,7 @@ class LoadAllFixturesWithPathnameTest < ActiveRecord::TestCase
fixtures :all
def test_all_there
- assert_equal %w(developers people tasks), fixture_table_names.sort
+ assert_equal %w(admin/accounts admin/users developers people tasks), fixture_table_names.sort
end
end
View
1  activerecord/test/fixtures/all/admin
View
2  activerecord/test/fixtures/to_be_linked/accounts.yml
@@ -0,0 +1,2 @@
+signals37:
+ name: 37signals
View
10 activerecord/test/fixtures/to_be_linked/users.yml
@@ -0,0 +1,10 @@
+david:
+ name: David
+ account: signals37
+
+jamis:
+ name: Jamis
+ account: signals37
+ settings:
+ :symbol: symbol
+ string: string
Please sign in to comment.
Something went wrong with that request. Please try again.