Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Change the behavior of db:test:clone task when schema_format is sql f…

…or consistency.
  • Loading branch information...
commit 9ab805d8809c11e6bc1d8db30f839e8c66dc66c0 1 parent 7d3e846
@kennyj authored
View
12 activerecord/lib/active_record/railties/databases.rake
@@ -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
9 railties/test/application/rake_test.rb
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.