aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKassio Borges <kassioborgesm@gmail.com>2013-08-05 16:35:49 -0300
committerKassio Borges <kassioborgesm@gmail.com>2013-08-05 16:35:49 -0300
commit4700d0279ccbf8571b8c90b9bedb69b4f0ecf1b1 (patch)
tree40bb5e9c19fe44a198a378e13d17253871d137af
parent77a0030316d2acc348cf9dda0452776d3457f8d5 (diff)
downloadrails-4700d0279ccbf8571b8c90b9bedb69b4f0ecf1b1.tar.gz
rails-4700d0279ccbf8571b8c90b9bedb69b4f0ecf1b1.tar.bz2
rails-4700d0279ccbf8571b8c90b9bedb69b4f0ecf1b1.zip
load fixtures from linked folders
-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