Skip to content
This repository
Browse code

Make sure that the build/drop database rake tasks take account of the…

… test/config.yml config
  • Loading branch information...
commit 499dec0102a30eab566ff3e58ff7148a0868cc6c 1 parent 5e21247
Jon Leighton authored June 06, 2011

Showing 1 changed file with 16 additions and 12 deletions. Show diff stats Hide diff stats

  1. 28  activerecord/Rakefile
28  activerecord/Rakefile
@@ -4,8 +4,7 @@ require 'rake/packagetask'
4 4
 require 'rubygems/package_task'
5 5
 
6 6
 require File.expand_path(File.dirname(__FILE__)) + "/test/config"
7  
-
8  
-MYSQL_DB_USER = 'rails'
  7
+require File.expand_path(File.dirname(__FILE__)) + "/test/support/config"
9 8
 
10 9
 def run_without_aborting(*tasks)
11 10
   errors = []
@@ -82,14 +81,16 @@ task :test_sqlite3 => [
82 81
 namespace :mysql do
83 82
   desc 'Build the MySQL test databases'
84 83
   task :build_databases do
85  
-    %x( mysql --user=#{MYSQL_DB_USER} -e "create DATABASE activerecord_unittest DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_unicode_ci ")
86  
-    %x( mysql --user=#{MYSQL_DB_USER} -e "create DATABASE activerecord_unittest2 DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_unicode_ci ")
  84
+    config = ARTest.config['connections']['mysql']
  85
+    %x( mysql --user=#{config['arunit']['username']} -e "create DATABASE #{config['arunit']['database']} DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_unicode_ci ")
  86
+    %x( mysql --user=#{config['arunit2']['username']} -e "create DATABASE #{config['arunit2']['database']} DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_unicode_ci ")
87 87
   end
88 88
 
89 89
   desc 'Drop the MySQL test databases'
90 90
   task :drop_databases do
91  
-    %x( mysqladmin --user=#{MYSQL_DB_USER} -f drop activerecord_unittest )
92  
-    %x( mysqladmin --user=#{MYSQL_DB_USER} -f drop activerecord_unittest2 )
  91
+    config = ARTest.config['connections']['mysql']
  92
+    %x( mysqladmin --user=#{config['arunit']['username']} -f drop #{config['arunit']['database']} )
  93
+    %x( mysqladmin --user=#{config['arunit2']['username']} -f drop #{config['arunit2']['database']} )
93 94
   end
94 95
 
95 96
   desc 'Rebuild the MySQL test databases'
@@ -104,14 +105,16 @@ task :rebuild_mysql_databases => 'mysql:rebuild_databases'
104 105
 namespace :postgresql do
105 106
   desc 'Build the PostgreSQL test databases'
106 107
   task :build_databases do
107  
-    %x( createdb -E UTF8 activerecord_unittest )
108  
-    %x( createdb -E UTF8 activerecord_unittest2 )
  108
+    config = ARTest.config['connections']['postgresql']
  109
+    %x( createdb -E UTF8 #{config['arunit']['database']} )
  110
+    %x( createdb -E UTF8 #{config['arunit2']['database']} )
109 111
   end
110 112
 
111 113
   desc 'Drop the PostgreSQL test databases'
112 114
   task :drop_databases do
113  
-    %x( dropdb activerecord_unittest )
114  
-    %x( dropdb activerecord_unittest2 )
  115
+    config = ARTest.config['connections']['postgresql']
  116
+    %x( dropdb #{config['arunit']['database']} )
  117
+    %x( dropdb #{config['arunit2']['database']} )
115 118
   end
116 119
 
117 120
   desc 'Rebuild the PostgreSQL test databases'
@@ -150,8 +153,9 @@ namespace :frontbase do
150 153
         DISCONNECT ALL;
151 154
       )
152 155
     end
153  
-    create_activerecord_unittest  = build_frontbase_database['activerecord_unittest',  File.join(SCHEMA_ROOT, 'frontbase.sql')]
154  
-    create_activerecord_unittest2 = build_frontbase_database['activerecord_unittest2', File.join(SCHEMA_ROOT, 'frontbase2.sql')]
  156
+    config = ARTest.config['connections']['frontbase']
  157
+    create_activerecord_unittest  = build_frontbase_database[config['arunit']['database'],  File.join(SCHEMA_ROOT, 'frontbase.sql')]
  158
+    create_activerecord_unittest2 = build_frontbase_database[config['arunit2']['database'], File.join(SCHEMA_ROOT, 'frontbase2.sql')]
155 159
     execute_frontbase_sql = Proc.new do |sql|
156 160
       system(<<-SHELL)
157 161
       /Library/FrontBase/bin/sql92 <<-SQL

0 notes on commit 499dec0

Please sign in to comment.
Something went wrong with that request. Please try again.