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

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

This commit is contained in:
kennyj 2012-06-26 02:33:08 +09:00
parent 7d3e846bf9
commit 9ab805d880
2 changed files with 20 additions and 1 deletions

View file

@ -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" ]

View file

@ -144,6 +144,15 @@ module ApplicationTests
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