aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorJon Leighton <j@jonathanleighton.com>2011-06-05 11:28:02 +0100
committerJon Leighton <j@jonathanleighton.com>2011-06-05 11:28:17 +0100
commit523c7c233052a3f3e1ac99adad4aad66f33a9364 (patch)
treec0984e6ab2b11ed47e7ff29ee22255da96f1cc00 /activerecord
parent3b7d100b519b8ade5b5932a26b2cbbbc4c648e6c (diff)
downloadrails-523c7c233052a3f3e1ac99adad4aad66f33a9364.tar.gz
rails-523c7c233052a3f3e1ac99adad4aad66f33a9364.tar.bz2
rails-523c7c233052a3f3e1ac99adad4aad66f33a9364.zip
Fix adapter_test.rb to make no assumptions about the database name
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/test/cases/adapter_test.rb9
-rw-r--r--activerecord/test/support/connection.rb11
2 files changed, 16 insertions, 4 deletions
diff --git a/activerecord/test/cases/adapter_test.rb b/activerecord/test/cases/adapter_test.rb
index 295d78284e..e7a3bb9ced 100644
--- a/activerecord/test/cases/adapter_test.rb
+++ b/activerecord/test/cases/adapter_test.rb
@@ -43,7 +43,7 @@ class AdapterTest < ActiveRecord::TestCase
def test_current_database
if @connection.respond_to?(:current_database)
- assert_equal ENV['ARUNIT_DB_NAME'] || "activerecord_unittest", @connection.current_database
+ assert_equal ARTest.connection_config['arunit']['database'], @connection.current_database
end
end
@@ -68,7 +68,12 @@ class AdapterTest < ActiveRecord::TestCase
begin
assert_nothing_raised do
ActiveRecord::Base.establish_connection(ActiveRecord::Base.configurations['arunit'].except(:database))
- ActiveRecord::Base.connection.execute "SELECT activerecord_unittest.pirates.*, activerecord_unittest2.courses.* FROM activerecord_unittest.pirates, activerecord_unittest2.courses"
+
+ config = ARTest.connection_config
+ ActiveRecord::Base.connection.execute(
+ "SELECT #{config['arunit']['database']}.pirates.*, #{config['arunit2']['database']}.courses.* " \
+ "FROM #{config['arunit']['database']}.pirates, #{config['arunit2']['database']}.courses"
+ )
end
ensure
ActiveRecord::Base.establish_connection 'arunit'
diff --git a/activerecord/test/support/connection.rb b/activerecord/test/support/connection.rb
index f4123c694d..fcd2e4dee5 100644
--- a/activerecord/test/support/connection.rb
+++ b/activerecord/test/support/connection.rb
@@ -2,11 +2,18 @@ require 'logger'
require_dependency 'models/course'
module ARTest
+ def self.connection_name
+ ENV['ARCONN'] || config['default_connection']
+ end
+
+ def self.connection_config
+ config['connections'][connection_name]
+ end
+
def self.connect
- connection_name = ENV['ARCONN'] || config['default_connection']
puts "Using #{connection_name}"
ActiveRecord::Base.logger = Logger.new("debug.log")
- ActiveRecord::Base.configurations = config['connections'][connection_name]
+ ActiveRecord::Base.configurations = connection_config
ActiveRecord::Base.establish_connection 'arunit'
Course.establish_connection 'arunit2'
end