diff options
author | Rafael França <rafaelmfranca@gmail.com> | 2016-03-17 10:27:48 -0300 |
---|---|---|
committer | Rafael França <rafaelmfranca@gmail.com> | 2016-03-17 10:27:48 -0300 |
commit | e3a476dba8ad3a016ee6e20c242c81bb7480f6e3 (patch) | |
tree | 06397a1249570c6d5d6428a14cfd961239404064 /activerecord/test/cases | |
parent | f5a5988352b165143f0f9d622707c351c1470882 (diff) | |
parent | 6ca9031ba3c389f71366c3e6abf069c6924c5acf (diff) | |
download | rails-e3a476dba8ad3a016ee6e20c242c81bb7480f6e3.tar.gz rails-e3a476dba8ad3a016ee6e20c242c81bb7480f6e3.tar.bz2 rails-e3a476dba8ad3a016ee6e20c242c81bb7480f6e3.zip |
Merge pull request #24201 from rails/rake-db-create
Creates development and test databases in db:migrate task
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r-- | activerecord/test/cases/tasks/database_tasks_test.rb | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/activerecord/test/cases/tasks/database_tasks_test.rb b/activerecord/test/cases/tasks/database_tasks_test.rb index 49df6628eb..429aeca1d9 100644 --- a/activerecord/test/cases/tasks/database_tasks_test.rb +++ b/activerecord/test/cases/tasks/database_tasks_test.rb @@ -161,21 +161,25 @@ module ActiveRecord with('database' => 'dev-db') ActiveRecord::Tasks::DatabaseTasks.expects(:create). with('database' => 'test-db') - ENV.expects(:[]).with('RAILS_ENV').returns(nil) ActiveRecord::Tasks::DatabaseTasks.create_current( ActiveSupport::StringInquirer.new('development') ) end - def test_creates_only_development_database_when_rails_env_is_development + def test_creates_test_and_development_databases_when_rails_env_is_development + old_env = ENV['RAILS_ENV'] + ENV['RAILS_ENV'] = 'development' ActiveRecord::Tasks::DatabaseTasks.expects(:create). with('database' => 'dev-db') - ENV.expects(:[]).with('RAILS_ENV').returns('development') + ActiveRecord::Tasks::DatabaseTasks.expects(:create). + with('database' => 'test-db') ActiveRecord::Tasks::DatabaseTasks.create_current( ActiveSupport::StringInquirer.new('development') ) + ensure + ENV['RAILS_ENV'] = old_env end def test_establishes_connection_for_the_given_environment @@ -282,21 +286,25 @@ module ActiveRecord with('database' => 'dev-db') ActiveRecord::Tasks::DatabaseTasks.expects(:drop). with('database' => 'test-db') - ENV.expects(:[]).with('RAILS_ENV').returns(nil) ActiveRecord::Tasks::DatabaseTasks.drop_current( ActiveSupport::StringInquirer.new('development') ) end - def test_drops_only_development_database_when_rails_env_is_development + def test_drops_testand_development_databases_when_rails_env_is_development + old_env = ENV['RAILS_ENV'] + ENV['RAILS_ENV'] = 'development' ActiveRecord::Tasks::DatabaseTasks.expects(:drop). with('database' => 'dev-db') - ENV.expects(:[]).with('RAILS_ENV').returns('development') + ActiveRecord::Tasks::DatabaseTasks.expects(:drop). + with('database' => 'test-db') ActiveRecord::Tasks::DatabaseTasks.drop_current( ActiveSupport::StringInquirer.new('development') ) + ensure + ENV['RAILS_ENV'] = old_env end end |