1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

remove duplicated fixture set names

If using namespaced fixtures, get following Ruby warning.

```
activerecord/lib/active_record/fixtures.rb:922: warning: method redefined; discarding old admin_foos
activerecord/lib/active_record/fixtures.rb:922: warning: previous definition of admin_foos was here
```

This is happening because of the multiple set the same path when setting the
fixture name. Fix to remove the duplicate path.
This commit is contained in:
yuuji.yaginuma 2016-09-11 21:43:03 +09:00
parent 7c3cc0902c
commit 1b128f8974
3 changed files with 5 additions and 3 deletions

View file

@ -902,7 +902,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}"].uniq
fixture_set_names.map! { |f| f[(fixture_path.to_s.size + 1)..-5] }
else
fixture_set_names = fixture_set_names.flatten.map(&:to_s)

View file

@ -728,7 +728,7 @@ class LoadAllFixturesTest < ActiveRecord::TestCase
self.class.fixtures :all
if File.symlink? FIXTURES_ROOT + "/all/admin"
assert_equal %w(admin/accounts admin/users developers people tasks), fixture_table_names.sort
assert_equal %w(admin/accounts admin/users developers namespaced/accounts people tasks), fixture_table_names.sort
end
ensure
ActiveRecord::FixtureSet.reset_cache
@ -741,7 +741,7 @@ class LoadAllFixturesWithPathnameTest < ActiveRecord::TestCase
self.class.fixtures :all
if File.symlink? FIXTURES_ROOT + "/all/admin"
assert_equal %w(admin/accounts admin/users developers people tasks), fixture_table_names.sort
assert_equal %w(admin/accounts admin/users developers namespaced/accounts people tasks), fixture_table_names.sort
end
ensure
ActiveRecord::FixtureSet.reset_cache

View file

@ -0,0 +1,2 @@
signals37:
name: 37signals