diff options
author | Roberto Miranda <rjmaltamar@gmail.com> | 2019-04-02 15:11:09 +0100 |
---|---|---|
committer | Roberto Miranda <rjmaltamar@gmail.com> | 2019-04-02 16:25:48 +0100 |
commit | 098e4d25f19f2b932841401fdc5e7340876d8ff2 (patch) | |
tree | 5087c84b4ec929db58b9663059fa0f92b927a8a0 /railties | |
parent | 8375b8ee6da72152193df409c91f7f35f71b6836 (diff) | |
download | rails-098e4d25f19f2b932841401fdc5e7340876d8ff2.tar.gz rails-098e4d25f19f2b932841401fdc5e7340876d8ff2.tar.bz2 rails-098e4d25f19f2b932841401fdc5e7340876d8ff2.zip |
Add test cases for rake db:prepare
Diffstat (limited to 'railties')
-rw-r--r-- | railties/test/application/rake/dbs_test.rb | 9 | ||||
-rw-r--r-- | railties/test/application/rake/multi_dbs_test.rb | 21 |
2 files changed, 30 insertions, 0 deletions
diff --git a/railties/test/application/rake/dbs_test.rb b/railties/test/application/rake/dbs_test.rb index a1e237fa7b..ba8de8adc9 100644 --- a/railties/test/application/rake/dbs_test.rb +++ b/railties/test/application/rake/dbs_test.rb @@ -553,6 +553,15 @@ module ApplicationTests end end end + + test "db:prepare setup the database" do + Dir.chdir(app_path) do + rails "generate", "model", "book", "title:string" + output = rails("db:prepare") + + assert_match /CreateBooks: migrated/, output + end + end end end end diff --git a/railties/test/application/rake/multi_dbs_test.rb b/railties/test/application/rake/multi_dbs_test.rb index d676e7486e..2c7cfbc0c6 100644 --- a/railties/test/application/rake/multi_dbs_test.rb +++ b/railties/test/application/rake/multi_dbs_test.rb @@ -137,6 +137,21 @@ module ApplicationTests end end + def db_prepare + Dir.chdir(app_path) do + generate_models_for_animals + output = rails("db:prepare") + + ActiveRecord::Base.configurations.configs_for(env_name: Rails.env).each do |db_config| + if db_config.spec_name == "primary" + assert_match(/CreateBooks: migrated/, output) + else + assert_match(/CreateDogs: migrated/, output) + end + end + end + end + def write_models_for_animals # make a directory for the animals migration FileUtils.mkdir_p("#{app_path}/db/animals_migrate") @@ -175,6 +190,7 @@ module ApplicationTests test "db:create and db:drop works on all databases for env" do require "#{app_path}/config/environment" + ActiveRecord::Base.configurations.configs_for(env_name: Rails.env).each do |db_config| db_create_and_drop db_config.spec_name, db_config.config["database"] end @@ -226,6 +242,11 @@ module ApplicationTests require "#{app_path}/config/environment" db_migrate_and_schema_cache_dump_and_schema_cache_clear end + + test "db:prepare works on all databases" do + require "#{app_path}/config/environment" + db_prepare + end end end end |