Skip to content

Commit

Permalink
fixed database connections for specs
Browse files Browse the repository at this point in the history
  • Loading branch information
mlomnicki committed Jul 19, 2011
1 parent 7bcb094 commit 628a1c6
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
11 changes: 6 additions & 5 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,16 @@ end

task :default => :spec

DBNAME = 'rhcore_test'
namespace :postgresql do
desc 'Build the PostgreSQL test databases'
task :build_databases do
%x( createdb -E UTF8 rh_core_unittest )
%x( createdb -E UTF8 #{DBNAME} )
end

desc 'Drop the PostgreSQL test databases'
task :drop_databases do
%x( dropdb rh_core_unittest )
%x( dropdb #{DBNAME} )
end

desc 'Rebuild the PostgreSQL test databases'
Expand All @@ -38,16 +39,16 @@ task :build_postgresql_databases => 'postgresql:build_databases'
task :drop_postgresql_databases => 'postgresql:drop_databases'
task :rebuild_postgresql_databases => 'postgresql:rebuild_databases'

MYSQL_DB_USER = 'rh_core'
MYSQL_DB_USER = 'rhcore'
namespace :mysql do
desc 'Build the MySQL test databases'
task :build_databases do
%x( echo "create DATABASE rh_core_unittest DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_unicode_ci " | mysql --user=#{MYSQL_DB_USER})
%x( echo "create DATABASE #{DBNAME} DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_unicode_ci " | mysql --user=#{MYSQL_DB_USER})
end

desc 'Drop the MySQL test databases'
task :drop_databases do
%x( mysqladmin --user=#{MYSQL_DB_USER} -f drop rh_core_unittest )
%x( mysqladmin --user=#{MYSQL_DB_USER} -f drop #{DBNAME} )
end

desc 'Rebuild the MySQL test databases'
Expand Down
5 changes: 2 additions & 3 deletions spec/connections/mysql/connection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,12 @@
ActiveRecord::Base.configurations = {
'redhillonrails' => {
:adapter => 'mysql',
:database => 'redhillonrails_core_test',
:username => 'redhillonrails',
:database => 'rhcore_test',
:username => 'rhcore',
:encoding => 'utf8',
:socket => '/var/run/mysqld/mysqld.sock',
:min_messages => 'warning'
}

}

ActiveRecord::Base.establish_connection 'redhillonrails'
4 changes: 2 additions & 2 deletions spec/connections/mysql2/connection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
ActiveRecord::Base.configurations = {
'redhillonrails' => {
:adapter => 'mysql2',
:database => 'redhillonrails_core_test',
:username => 'redhillonrails',
:database => 'rhcore_test',
:username => 'rhcore',
:encoding => 'utf8',
:socket => '/var/run/mysqld/mysqld.sock',
:min_messages => 'warning'
Expand Down
2 changes: 1 addition & 1 deletion spec/connections/postgresql/connection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
ActiveRecord::Base.configurations = {
'redhillonrails' => {
:adapter => 'postgresql',
:database => 'redhillonrails_core_test',
:database => 'rhcore_test',
:min_messages => 'warning'
}

Expand Down

0 comments on commit 628a1c6

Please sign in to comment.