diff options
author | bogdanvlviv <bogdanvlviv@gmail.com> | 2017-08-25 23:05:21 +0300 |
---|---|---|
committer | bogdanvlviv <bogdanvlviv@gmail.com> | 2017-10-30 20:10:09 +0000 |
commit | c4867b88f6eed16230a90077b82ad02293ea45b3 (patch) | |
tree | 6d51ed5dd043515add818674c374d6325783d9a0 /activerecord/test/cases/tasks | |
parent | 13c5aa818e9284fe30f83469b340e579195bda3f (diff) | |
download | rails-c4867b88f6eed16230a90077b82ad02293ea45b3.tar.gz rails-c4867b88f6eed16230a90077b82ad02293ea45b3.tar.bz2 rails-c4867b88f6eed16230a90077b82ad02293ea45b3.zip |
Raise error if unsupported charset for mysql
`blog$ bin/rails db:create`
Before:
```
Couldn't create database for {"adapter"=>"mysql2", "encoding"=>"utf42", "pool"=>5,
"username"=>"root", "password"=>nil, "socket"=>"/var/run/mysqld/mysqld.sock",
"database"=>"blog_development"}, {:charset=>"utf42"}
(If you set the charset manually, make sure you have a matching collation)
Created database 'blog_development'
Couldn't create database for {"adapter"=>"mysql2", "encoding"=>"utf42", "pool"=>5,
"username"=>"root", "password"=>nil, "socket"=>"/var/run/mysqld/mysqld.sock",
"database"=>"blog_test"}, {:charset=>"utf42"}
(If you set the charset manually, make sure you have a matching collation)
Created database 'blog_test'
```
After:
```
Unsupported charset: '"utf42"'
Couldn't create database for {"adapter"=>"mysql2", "encoding"=>"utf42", "pool"=>5,
"username"=>"root", "password"=>nil, "socket"=>"/var/run/mysqld/mysqld.sock",
"database"=>"blog_development"}
rails aborted!
Mysql2::Error: Unsupported charset: '"utf42"'
...
(stack trace)
...
bin/rails:4:in `<main>'
Tasks: TOP => db:create
(See full trace by running task with --trace)
```
Closes #29683
Related to #27398
Diffstat (limited to 'activerecord/test/cases/tasks')
-rw-r--r-- | activerecord/test/cases/tasks/mysql_rake_test.rb | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/activerecord/test/cases/tasks/mysql_rake_test.rb b/activerecord/test/cases/tasks/mysql_rake_test.rb index 98fe24baa0..6c9b0040ad 100644 --- a/activerecord/test/cases/tasks/mysql_rake_test.rb +++ b/activerecord/test/cases/tasks/mysql_rake_test.rb @@ -156,12 +156,12 @@ if current_adapter?(:Mysql2Adapter) ActiveRecord::Tasks::DatabaseTasks.create @configuration end - def test_sends_output_to_stderr_when_other_errors + def test_raises_error_when_other_errors @error.stubs(:errno).returns(42) - $stderr.expects(:puts).at_least_once.returns(nil) - - ActiveRecord::Tasks::DatabaseTasks.create @configuration + assert_raises(Mysql2::Error) do + ActiveRecord::Tasks::DatabaseTasks.create @configuration + end end private |