aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2013-08-05 12:42:29 -0700
committerRafael Mendonça França <rafaelmfranca@gmail.com>2013-08-05 12:42:29 -0700
commit9b6a434defe7aed00f01643abdbc79751dc9d5f1 (patch)
treec943e5a249cf74953dac438d5232352d3513e6eb
parent6da48e92dd9c16d882dd335e967b368cfede7ede (diff)
parent4700d0279ccbf8571b8c90b9bedb69b4f0ecf1b1 (diff)
downloadrails-9b6a434defe7aed00f01643abdbc79751dc9d5f1.tar.gz
rails-9b6a434defe7aed00f01643abdbc79751dc9d5f1.tar.bz2
rails-9b6a434defe7aed00f01643abdbc79751dc9d5f1.zip
Merge pull request #11767 from kassio/master-load-fixtures-from-linked-folder
Load fixtures from linked folders[master]
-rw-r--r--activerecord/lib/active_record/fixtures.rb4
-rw-r--r--activerecord/test/cases/fixtures_test.rb4
l---------activerecord/test/fixtures/all/admin1
-rw-r--r--activerecord/test/fixtures/to_be_linked/accounts.yml2
-rw-r--r--activerecord/test/fixtures/to_be_linked/users.yml10
5 files changed, 17 insertions, 4 deletions
diff --git a/activerecord/lib/active_record/fixtures.rb b/activerecord/lib/active_record/fixtures.rb
index 20ca4e3c91..b2a81a184a 100644
--- a/activerecord/lib/active_record/fixtures.rb
+++ b/activerecord/lib/active_record/fixtures.rb
@@ -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 }
diff --git a/activerecord/test/cases/fixtures_test.rb b/activerecord/test/cases/fixtures_test.rb
index 2aa56ebc55..c07c9c3b74 100644
--- a/activerecord/test/cases/fixtures_test.rb
+++ b/activerecord/test/cases/fixtures_test.rb
@@ -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
diff --git a/activerecord/test/fixtures/all/admin b/activerecord/test/fixtures/all/admin
new file mode 120000
index 0000000000..984d12a043
--- /dev/null
+++ b/activerecord/test/fixtures/all/admin
@@ -0,0 +1 @@
+../to_be_linked/ \ No newline at end of file
diff --git a/activerecord/test/fixtures/to_be_linked/accounts.yml b/activerecord/test/fixtures/to_be_linked/accounts.yml
new file mode 100644
index 0000000000..9e341a15af
--- /dev/null
+++ b/activerecord/test/fixtures/to_be_linked/accounts.yml
@@ -0,0 +1,2 @@
+signals37:
+ name: 37signals
diff --git a/activerecord/test/fixtures/to_be_linked/users.yml b/activerecord/test/fixtures/to_be_linked/users.yml
new file mode 100644
index 0000000000..e2884beda5
--- /dev/null
+++ b/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