diff options
author | Jon Leighton <j@jonathanleighton.com> | 2011-06-06 20:37:23 +0100 |
---|---|---|
committer | Jon Leighton <j@jonathanleighton.com> | 2011-06-06 21:27:28 +0100 |
commit | 499dec0102a30eab566ff3e58ff7148a0868cc6c (patch) | |
tree | d91367bc4025951940ef60479eea6595730fade6 /activerecord | |
parent | 5e21247131fa7d5484190c9a71b74f9d3f090684 (diff) | |
download | rails-499dec0102a30eab566ff3e58ff7148a0868cc6c.tar.gz rails-499dec0102a30eab566ff3e58ff7148a0868cc6c.tar.bz2 rails-499dec0102a30eab566ff3e58ff7148a0868cc6c.zip |
Make sure that the build/drop database rake tasks take account of the test/config.yml config
Diffstat (limited to 'activerecord')
-rwxr-xr-x | activerecord/Rakefile | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/activerecord/Rakefile b/activerecord/Rakefile index d5863ab14d..27e8eda876 100755 --- a/activerecord/Rakefile +++ b/activerecord/Rakefile @@ -4,8 +4,7 @@ require 'rake/packagetask' require 'rubygems/package_task' require File.expand_path(File.dirname(__FILE__)) + "/test/config" - -MYSQL_DB_USER = 'rails' +require File.expand_path(File.dirname(__FILE__)) + "/test/support/config" def run_without_aborting(*tasks) errors = [] @@ -82,14 +81,16 @@ task :test_sqlite3 => [ namespace :mysql do desc 'Build the MySQL test databases' task :build_databases do - %x( mysql --user=#{MYSQL_DB_USER} -e "create DATABASE activerecord_unittest DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_unicode_ci ") - %x( mysql --user=#{MYSQL_DB_USER} -e "create DATABASE activerecord_unittest2 DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_unicode_ci ") + config = ARTest.config['connections']['mysql'] + %x( mysql --user=#{config['arunit']['username']} -e "create DATABASE #{config['arunit']['database']} DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_unicode_ci ") + %x( mysql --user=#{config['arunit2']['username']} -e "create DATABASE #{config['arunit2']['database']} DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_unicode_ci ") end desc 'Drop the MySQL test databases' task :drop_databases do - %x( mysqladmin --user=#{MYSQL_DB_USER} -f drop activerecord_unittest ) - %x( mysqladmin --user=#{MYSQL_DB_USER} -f drop activerecord_unittest2 ) + config = ARTest.config['connections']['mysql'] + %x( mysqladmin --user=#{config['arunit']['username']} -f drop #{config['arunit']['database']} ) + %x( mysqladmin --user=#{config['arunit2']['username']} -f drop #{config['arunit2']['database']} ) end desc 'Rebuild the MySQL test databases' @@ -104,14 +105,16 @@ task :rebuild_mysql_databases => 'mysql:rebuild_databases' namespace :postgresql do desc 'Build the PostgreSQL test databases' task :build_databases do - %x( createdb -E UTF8 activerecord_unittest ) - %x( createdb -E UTF8 activerecord_unittest2 ) + config = ARTest.config['connections']['postgresql'] + %x( createdb -E UTF8 #{config['arunit']['database']} ) + %x( createdb -E UTF8 #{config['arunit2']['database']} ) end desc 'Drop the PostgreSQL test databases' task :drop_databases do - %x( dropdb activerecord_unittest ) - %x( dropdb activerecord_unittest2 ) + config = ARTest.config['connections']['postgresql'] + %x( dropdb #{config['arunit']['database']} ) + %x( dropdb #{config['arunit2']['database']} ) end desc 'Rebuild the PostgreSQL test databases' @@ -150,8 +153,9 @@ namespace :frontbase do DISCONNECT ALL; ) end - create_activerecord_unittest = build_frontbase_database['activerecord_unittest', File.join(SCHEMA_ROOT, 'frontbase.sql')] - create_activerecord_unittest2 = build_frontbase_database['activerecord_unittest2', File.join(SCHEMA_ROOT, 'frontbase2.sql')] + config = ARTest.config['connections']['frontbase'] + create_activerecord_unittest = build_frontbase_database[config['arunit']['database'], File.join(SCHEMA_ROOT, 'frontbase.sql')] + create_activerecord_unittest2 = build_frontbase_database[config['arunit2']['database'], File.join(SCHEMA_ROOT, 'frontbase2.sql')] execute_frontbase_sql = Proc.new do |sql| system(<<-SHELL) /Library/FrontBase/bin/sql92 <<-SQL |