diff options
author | Carlos Antonio da Silva <carlosantoniodasilva@gmail.com> | 2013-01-09 00:58:23 -0200 |
---|---|---|
committer | Carlos Antonio da Silva <carlosantoniodasilva@gmail.com> | 2013-01-12 09:28:13 -0200 |
commit | 9b636dcf53e4ac410186a720d5bef783fc8648c4 (patch) | |
tree | 4eb46d9fbc6c85cdcd29028d6d6853957a910f7f /activerecord/test | |
parent | c1d722558ee2bd373ca4768c48b8ae944e1bdb05 (diff) | |
download | rails-9b636dcf53e4ac410186a720d5bef783fc8648c4.tar.gz rails-9b636dcf53e4ac410186a720d5bef783fc8648c4.tar.bz2 rails-9b636dcf53e4ac410186a720d5bef783fc8648c4.zip |
Bring back "database already exists" messages when running rake tasks
When running tasks such "rake db:setup", instead of showing messages
like "db_development already exists", it was showing a big stack trace
and a message "Couldn't create database for ..." with the configuration
options, a very confusing message with a big trace.
This brings back the functionality present in 3-2, showing the same
message.
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/tasks/database_tasks_test.rb | 14 | ||||
-rw-r--r-- | activerecord/test/cases/tasks/mysql_rake_test.rb | 10 | ||||
-rw-r--r-- | activerecord/test/cases/tasks/postgresql_rake_test.rb | 10 |
3 files changed, 27 insertions, 7 deletions
diff --git a/activerecord/test/cases/tasks/database_tasks_test.rb b/activerecord/test/cases/tasks/database_tasks_test.rb index 4f3489b7a5..659d5eae72 100644 --- a/activerecord/test/cases/tasks/database_tasks_test.rb +++ b/activerecord/test/cases/tasks/database_tasks_test.rb @@ -11,10 +11,10 @@ module ActiveRecord end ADAPTERS_TASKS = { - :mysql => :mysql_tasks, - :mysql2 => :mysql_tasks, - :postgresql => :postgresql_tasks, - :sqlite3 => :sqlite_tasks + mysql: :mysql_tasks, + mysql2: :mysql_tasks, + postgresql: :postgresql_tasks, + sqlite3: :sqlite_tasks } class DatabaseTasksRegisterTask < ActiveRecord::TestCase @@ -32,7 +32,7 @@ module ActiveRecord ActiveRecord::Tasks::DatabaseTasks.structure_dump({'adapter' => :foo}, "awesome-file.sql") end end - + class DatabaseTasksCreateTest < ActiveRecord::TestCase include DatabaseTasksSetupper @@ -258,7 +258,7 @@ module ActiveRecord class DatabaseTasksCharsetTest < ActiveRecord::TestCase include DatabaseTasksSetupper - + ADAPTERS_TASKS.each do |k, v| define_method("test_#{k}_charset") do eval("@#{v}").expects(:charset) @@ -269,7 +269,7 @@ module ActiveRecord class DatabaseTasksCollationTest < ActiveRecord::TestCase include DatabaseTasksSetupper - + ADAPTERS_TASKS.each do |k, v| define_method("test_#{k}_collation") do eval("@#{v}").expects(:collation) diff --git a/activerecord/test/cases/tasks/mysql_rake_test.rb b/activerecord/test/cases/tasks/mysql_rake_test.rb index 69a049fcfa..38b9dd02f0 100644 --- a/activerecord/test/cases/tasks/mysql_rake_test.rb +++ b/activerecord/test/cases/tasks/mysql_rake_test.rb @@ -53,6 +53,16 @@ module ActiveRecord ActiveRecord::Tasks::DatabaseTasks.create @configuration end + + def test_create_when_database_exists_outputs_info_to_stderr + $stderr.expects(:puts).with("my-app-db already exists").once + + ActiveRecord::Base.connection.stubs(:create_database).raises( + ActiveRecord::StatementInvalid.new("Can't create database 'dev'; database exists:") + ) + + ActiveRecord::Tasks::DatabaseTasks.create @configuration + end end class MysqlDBCreateAsRootTest < ActiveRecord::TestCase diff --git a/activerecord/test/cases/tasks/postgresql_rake_test.rb b/activerecord/test/cases/tasks/postgresql_rake_test.rb index 62acd53003..3006a87589 100644 --- a/activerecord/test/cases/tasks/postgresql_rake_test.rb +++ b/activerecord/test/cases/tasks/postgresql_rake_test.rb @@ -61,6 +61,16 @@ module ActiveRecord ActiveRecord::Tasks::DatabaseTasks.create @configuration end + + def test_create_when_database_exists_outputs_info_to_stderr + $stderr.expects(:puts).with("my-app-db already exists").once + + ActiveRecord::Base.connection.stubs(:create_database).raises( + ActiveRecord::StatementInvalid.new('database "my-app-db" already exists') + ) + + ActiveRecord::Tasks::DatabaseTasks.create @configuration + end end class PostgreSQLDBDropTest < ActiveRecord::TestCase |