aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2013-08-05 12:56:31 -0700
committerRafael Mendonça França <rafaelmfranca@gmail.com>2013-08-05 12:56:31 -0700
commit5f8a7d1d4d867d87e74b378d357f8476f91e7852 (patch)
tree07fda07a47eb75514508dd1d1703a0a429b3d42f /activerecord
parent773eca0e12af14cbd52f71fff9387e6abcfc4f1f (diff)
parent0ec701d50bebf8ebd08015565ec771fb14357d8d (diff)
downloadrails-5f8a7d1d4d867d87e74b378d357f8476f91e7852.tar.gz
rails-5f8a7d1d4d867d87e74b378d357f8476f91e7852.tar.bz2
rails-5f8a7d1d4d867d87e74b378d357f8476f91e7852.zip
Merge pull request #11765 from kassio/load-fixtures-from-linked-folder
Load fixtures from linked folder
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/CHANGELOG.md4
-rw-r--r--activerecord/lib/active_record/fixtures.rb4
-rw-r--r--activerecord/test/cases/fixtures_test.rb2
l---------activerecord/test/fixtures/all/admin1
4 files changed, 8 insertions, 3 deletions
diff --git a/activerecord/CHANGELOG.md b/activerecord/CHANGELOG.md
index a068d04fbd..5abc84d3fb 100644
--- a/activerecord/CHANGELOG.md
+++ b/activerecord/CHANGELOG.md
@@ -1,5 +1,9 @@
## unreleased ##
+* Load fixtures from linked folders.
+
+ *Kassio Borges*
+
* When using optimistic locking, `update` was not passing the column to `quote_value`
to allow the connection adapter to properly determine how to quote the value. This was
affecting certain databases that use specific colmn types.
diff --git a/activerecord/lib/active_record/fixtures.rb b/activerecord/lib/active_record/fixtures.rb
index 7a5634f225..1e6b5c5d69 100644
--- a/activerecord/lib/active_record/fixtures.rb
+++ b/activerecord/lib/active_record/fixtures.rb
@@ -661,7 +661,7 @@ module ActiveRecord
end
def read_fixture_files
- yaml_files = Dir["#{@fixture_path}/**/*.yml"].select { |f|
+ yaml_files = Dir["#{@fixture_path}/{**,*}/*.yml"].select { |f|
::File.file?(f)
} + [yaml_file_path]
@@ -752,7 +752,7 @@ module ActiveRecord
def fixtures(*fixture_names)
if fixture_names.first == :all
- fixture_names = Dir["#{fixture_path}/**/*.{yml}"]
+ fixture_names = Dir["#{fixture_path}/{**,*}/*.{yml}"]
fixture_names.map! { |f| f[(fixture_path.size + 1)..-5] }
else
fixture_names = fixture_names.flatten.map { |n| n.to_s }
diff --git a/activerecord/test/cases/fixtures_test.rb b/activerecord/test/cases/fixtures_test.rb
index 99dd74c561..4c7da6e5c5 100644
--- a/activerecord/test/cases/fixtures_test.rb
+++ b/activerecord/test/cases/fixtures_test.rb
@@ -549,7 +549,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
diff --git a/activerecord/test/fixtures/all/admin b/activerecord/test/fixtures/all/admin
new file mode 120000
index 0000000000..59636afce2
--- /dev/null
+++ b/activerecord/test/fixtures/all/admin
@@ -0,0 +1 @@
+../admin/ \ No newline at end of file