1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Make sure recreate MySQL test database with the proper encoding and collation [#1165 state:resolved]

Signed-off-by: Michael Koziarski <michael@koziarski.com>
[#1165 state:committed]
This commit is contained in:
Luca Guidi 2008-10-03 16:08:17 +02:00 committed by Michael Koziarski
parent 7553a23c0a
commit 1bc267d216
3 changed files with 8 additions and 3 deletions

View file

@ -371,9 +371,9 @@ module ActiveRecord
end
end
def recreate_database(name) #:nodoc:
def recreate_database(name, options = {}) #:nodoc:
drop_database(name)
create_database(name)
create_database(name, options)
end
# Create a new MySQL database with optional <tt>:charset</tt> and <tt>:collation</tt>.

View file

@ -25,6 +25,11 @@ class ActiveSchemaTest < ActiveRecord::TestCase
assert_equal "CREATE DATABASE `aimonetti` DEFAULT CHARACTER SET `latin1`", create_database(:aimonetti, {:charset => 'latin1'})
assert_equal "CREATE DATABASE `matt_aimonetti` DEFAULT CHARACTER SET `big5` COLLATE `big5_chinese_ci`", create_database(:matt_aimonetti, {:charset => :big5, :collation => :big5_chinese_ci})
end
def test_recreate_mysql_database_with_encoding
create_database(:luca, {:charset => 'latin1'})
assert_equal "CREATE DATABASE `luca` DEFAULT CHARACTER SET `latin1`", recreate_database(:luca, {:charset => 'latin1'})
end
end
def test_add_column

View file

@ -341,7 +341,7 @@ namespace :db do
case abcs["test"]["adapter"]
when "mysql"
ActiveRecord::Base.establish_connection(:test)
ActiveRecord::Base.connection.recreate_database(abcs["test"]["database"])
ActiveRecord::Base.connection.recreate_database(abcs["test"]["database"], abcs["test"])
when "postgresql"
ActiveRecord::Base.clear_active_connections!
drop_database(abcs['test'])