提交 9ab805d8 编写于 作者: K kennyj

Change the behavior of db:test:clone task when schema_format is sql for consistency.

上级 7d3e846b
......@@ -355,8 +355,18 @@ db_namespace = namespace :db do
end
end
# desc "Recreate the test database from a fresh schema"
task :clone do
case ActiveRecord::Base.schema_format
when :ruby
db_namespace["test:clone_schema"].invoke
when :sql
db_namespace["test:clone_structure"].invoke
end
end
# desc "Recreate the test database from a fresh schema.rb file"
task :clone => %w(db:schema:dump db:test:load_schema)
task :clone_schema => ["db:schema:dump", "db:test:load_schema"]
# desc "Recreate the test database from a fresh structure.sql file"
task :clone_structure => [ "db:structure:dump", "db:test:load_structure" ]
......
......@@ -144,6 +144,15 @@ def test_scaffold_tests_pass_by_default
assert_no_match(/Errors running/, output)
end
def test_db_test_clone_when_using_sql_format
add_to_config "config.active_record.schema_format = :sql"
output = Dir.chdir(app_path) do
`rails generate scaffold user username:string;
bundle exec rake db:migrate db:test:clone 2>&1 --trace`
end
assert_match(/Execute db:test:clone_structure/, output)
end
def test_rake_dump_structure_should_respect_db_structure_env_variable
Dir.chdir(app_path) do
# ensure we have a schema_migrations table to dump
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册