提交 98996977 编写于 作者: G Gannon McGibbon

Stop trying to read yaml file fixtures when loading Active Record fixtures

上级 61bda21e
* Stop trying to read yaml file fixtures when loading Active Record fixtures.
*Gannon McGibbon*
* Deprecate `.reorder(nil)` with `.first` / `.first!` taking non-deterministic result.
To continue taking non-deterministic result, use `.take` / `.take!` instead.
......
......@@ -41,8 +41,9 @@ def set_fixture_class(class_names = {})
def fixtures(*fixture_set_names)
if fixture_set_names.first == :all
raise StandardError, "No fixture path found. Please set `#{self}.fixture_path`." if fixture_path.blank?
fixture_set_names = Dir["#{fixture_path}/{**,*}/*.{yml}"].uniq
fixture_set_names.map! { |f| f[(fixture_path.to_s.size + 1)..-5] }
fixture_set_names = Dir[::File.join(fixture_path, "{**,*}/*.{yml}")].uniq
fixture_set_names.reject! { |f| f.starts_with?(file_fixture_path.to_s) } if file_fixture_path
fixture_set_names.map! { |f| f[fixture_path.to_s.size..-5].delete_prefix("/") }
else
fixture_set_names = fixture_set_names.flatten.map(&:to_s)
end
......
......@@ -1371,6 +1371,19 @@ class NilFixturePathTest < ActiveRecord::TestCase
end
end
class FileFixtureConflictTest < ActiveRecord::TestCase
def self.file_fixture_path
FIXTURES_ROOT + "/all/admin"
end
test "ignores file fixtures" do
self.class.fixture_path = FIXTURES_ROOT + "/all"
self.class.fixtures :all
assert_equal %w(developers namespaced/accounts people tasks), fixture_table_names.sort
end
end
class MultipleDatabaseFixturesTest < ActiveRecord::TestCase
test "enlist_fixture_connections ensures multiple databases share a connection pool" do
with_temporary_connection_pool do
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册