mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
load fixtures from linked folders
This commit is contained in:
parent
77a0030316
commit
4700d0279c
5 changed files with 17 additions and 4 deletions
|
@ -637,7 +637,7 @@ module ActiveRecord
|
|||
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]
|
||||
|
||||
|
@ -756,7 +756,7 @@ module ActiveRecord
|
|||
|
||||
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 }
|
||||
|
|
|
@ -584,7 +584,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
|
||||
|
||||
|
@ -593,7 +593,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
|
||||
|
||||
|
|
1
activerecord/test/fixtures/all/admin
vendored
Symbolic link
1
activerecord/test/fixtures/all/admin
vendored
Symbolic link
|
@ -0,0 +1 @@
|
|||
../to_be_linked/
|
2
activerecord/test/fixtures/to_be_linked/accounts.yml
vendored
Normal file
2
activerecord/test/fixtures/to_be_linked/accounts.yml
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
signals37:
|
||||
name: 37signals
|
10
activerecord/test/fixtures/to_be_linked/users.yml
vendored
Normal file
10
activerecord/test/fixtures/to_be_linked/users.yml
vendored
Normal file
|
@ -0,0 +1,10 @@
|
|||
david:
|
||||
name: David
|
||||
account: signals37
|
||||
|
||||
jamis:
|
||||
name: Jamis
|
||||
account: signals37
|
||||
settings:
|
||||
:symbol: symbol
|
||||
string: string
|
Loading…
Reference in a new issue