Skip to content

Commit

Permalink
Fix CI
Browse files Browse the repository at this point in the history
  • Loading branch information
jonleighton committed Dec 28, 2011
1 parent e99987b commit f06074f
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 25 deletions.
6 changes: 3 additions & 3 deletions activerecord/test/cases/adapter_test.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -69,16 +69,16 @@ def test_show_nonexistent_variable_returns_nil
def test_not_specifying_database_name_for_cross_database_selects def test_not_specifying_database_name_for_cross_database_selects
begin begin
assert_nothing_raised do assert_nothing_raised do
ActiveRecord::Base.establish_connection(ActiveRecord::Base.configurations['arunit'].except(:database)) ActiveRecord::Model.establish_connection(ActiveRecord::Base.configurations['arunit'].except(:database))


config = ARTest.connection_config config = ARTest.connection_config
ActiveRecord::Base.connection.execute( ActiveRecord::Model.connection.execute(
"SELECT #{config['arunit']['database']}.pirates.*, #{config['arunit2']['database']}.courses.* " \ "SELECT #{config['arunit']['database']}.pirates.*, #{config['arunit2']['database']}.courses.* " \
"FROM #{config['arunit']['database']}.pirates, #{config['arunit2']['database']}.courses" "FROM #{config['arunit']['database']}.pirates, #{config['arunit2']['database']}.courses"
) )
end end
ensure ensure
ActiveRecord::Base.establish_connection 'arunit' ActiveRecord::Model.establish_connection 'arunit'
end end
end end
end end
Expand Down
16 changes: 8 additions & 8 deletions activerecord/test/cases/adapters/mysql/connection_test.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
class MysqlConnectionTest < ActiveRecord::TestCase class MysqlConnectionTest < ActiveRecord::TestCase
def setup def setup
super super
@connection = ActiveRecord::Base.connection @connection = ActiveRecord::Model.connection
end end


def test_mysql_reconnect_attribute_after_connection_with_reconnect_true def test_mysql_reconnect_attribute_after_connection_with_reconnect_true
run_without_connection do |orig_connection| run_without_connection do |orig_connection|
ActiveRecord::Base.establish_connection(orig_connection.merge({:reconnect => true})) ActiveRecord::Model.establish_connection(orig_connection.merge({:reconnect => true}))
assert ActiveRecord::Base.connection.raw_connection.reconnect assert ActiveRecord::Model.connection.raw_connection.reconnect
end end
end end


Expand All @@ -25,8 +25,8 @@ def test_connect_with_url


def test_mysql_reconnect_attribute_after_connection_with_reconnect_false def test_mysql_reconnect_attribute_after_connection_with_reconnect_false
run_without_connection do |orig_connection| run_without_connection do |orig_connection|
ActiveRecord::Base.establish_connection(orig_connection.merge({:reconnect => false})) ActiveRecord::Model.establish_connection(orig_connection.merge({:reconnect => false}))
assert !ActiveRecord::Base.connection.raw_connection.reconnect assert !ActiveRecord::Model.connection.raw_connection.reconnect
end end
end end


Expand Down Expand Up @@ -114,7 +114,7 @@ def test_exec_typecasts_bind_vals
# Test that MySQL allows multiple results for stored procedures # Test that MySQL allows multiple results for stored procedures
if defined?(Mysql) && Mysql.const_defined?(:CLIENT_MULTI_RESULTS) if defined?(Mysql) && Mysql.const_defined?(:CLIENT_MULTI_RESULTS)
def test_multi_results def test_multi_results
rows = ActiveRecord::Base.connection.select_rows('CALL ten();') rows = ActiveRecord::Model.connection.select_rows('CALL ten();')
assert_equal 10, rows[0][0].to_i, "ten() did not return 10 as expected: #{rows.inspect}" assert_equal 10, rows[0][0].to_i, "ten() did not return 10 as expected: #{rows.inspect}"
assert @connection.active?, "Bad connection use by 'MysqlAdapter.select_rows'" assert @connection.active?, "Bad connection use by 'MysqlAdapter.select_rows'"
end end
Expand All @@ -123,11 +123,11 @@ def test_multi_results
private private


def run_without_connection def run_without_connection
original_connection = ActiveRecord::Base.remove_connection original_connection = ActiveRecord::Model.remove_connection
begin begin
yield original_connection yield original_connection
ensure ensure
ActiveRecord::Base.establish_connection(original_connection) ActiveRecord::Model.establish_connection(original_connection)
end end
end end
end end
6 changes: 3 additions & 3 deletions activerecord/test/cases/adapters/mysql2/connection_test.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
class MysqlConnectionTest < ActiveRecord::TestCase class MysqlConnectionTest < ActiveRecord::TestCase
def setup def setup
super super
@connection = ActiveRecord::Base.connection @connection = ActiveRecord::Model.connection
end end


def test_no_automatic_reconnection_after_timeout def test_no_automatic_reconnection_after_timeout
Expand Down Expand Up @@ -32,11 +32,11 @@ def test_successful_reconnection_after_timeout_with_verify
private private


def run_without_connection def run_without_connection
original_connection = ActiveRecord::Base.remove_connection original_connection = ActiveRecord::Model.remove_connection
begin begin
yield original_connection yield original_connection
ensure ensure
ActiveRecord::Base.establish_connection(original_connection) ActiveRecord::Model.establish_connection(original_connection)
end end
end end
end end
18 changes: 9 additions & 9 deletions activerecord/test/cases/pooled_connections_test.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@ class PooledConnectionsTest < ActiveRecord::TestCase


def setup def setup
@per_test_teardown = [] @per_test_teardown = []
@connection = ActiveRecord::Base.remove_connection @connection = ActiveRecord::Model.remove_connection
end end


def teardown def teardown
ActiveRecord::Base.clear_all_connections! ActiveRecord::Model.clear_all_connections!
ActiveRecord::Base.establish_connection(@connection) ActiveRecord::Model.establish_connection(@connection)
@per_test_teardown.each {|td| td.call } @per_test_teardown.each {|td| td.call }
end end


def checkout_connections def checkout_connections
ActiveRecord::Base.establish_connection(@connection.merge({:pool => 2, :wait_timeout => 0.3})) ActiveRecord::Model.establish_connection(@connection.merge({:pool => 2, :wait_timeout => 0.3}))
@connections = [] @connections = []
@timed_out = 0 @timed_out = 0


Expand All @@ -34,15 +34,15 @@ def checkout_connections


# Will deadlock due to lack of Monitor timeouts in 1.9 # Will deadlock due to lack of Monitor timeouts in 1.9
def checkout_checkin_connections(pool_size, threads) def checkout_checkin_connections(pool_size, threads)
ActiveRecord::Base.establish_connection(@connection.merge({:pool => pool_size, :wait_timeout => 0.5})) ActiveRecord::Model.establish_connection(@connection.merge({:pool => pool_size, :wait_timeout => 0.5}))
@connection_count = 0 @connection_count = 0
@timed_out = 0 @timed_out = 0
threads.times do threads.times do
Thread.new do Thread.new do
begin begin
conn = ActiveRecord::Base.connection_pool.checkout conn = ActiveRecord::Model.connection_pool.checkout
sleep 0.1 sleep 0.1
ActiveRecord::Base.connection_pool.checkin conn ActiveRecord::Model.connection_pool.checkin conn
@connection_count += 1 @connection_count += 1
rescue ActiveRecord::ConnectionTimeoutError rescue ActiveRecord::ConnectionTimeoutError
@timed_out += 1 @timed_out += 1
Expand All @@ -55,13 +55,13 @@ def test_pooled_connection_checkin_one
checkout_checkin_connections 1, 2 checkout_checkin_connections 1, 2
assert_equal 2, @connection_count assert_equal 2, @connection_count
assert_equal 0, @timed_out assert_equal 0, @timed_out
assert_equal 1, ActiveRecord::Base.connection_pool.connections.size assert_equal 1, ActiveRecord::Model.connection_pool.connections.size
end end




private private


def add_record(name) def add_record(name)
ActiveRecord::Base.connection_pool.with_connection { Project.create! :name => name } ActiveRecord::Model.connection_pool.with_connection { Project.create! :name => name }
end end
end unless current_adapter?(:FrontBase) || in_memory_db? end unless current_adapter?(:FrontBase) || in_memory_db?
4 changes: 2 additions & 2 deletions activerecord/test/cases/primary_keys_test.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -188,14 +188,14 @@ class PrimaryKeyWithNoConnectionTest < ActiveRecord::TestCase
def test_set_primary_key_with_no_connection def test_set_primary_key_with_no_connection
return skip("disconnect wipes in-memory db") if in_memory_db? return skip("disconnect wipes in-memory db") if in_memory_db?


connection = ActiveRecord::Base.remove_connection connection = ActiveRecord::Model.remove_connection


model = Class.new(ActiveRecord::Base) model = Class.new(ActiveRecord::Base)
model.primary_key = 'foo' model.primary_key = 'foo'


assert_equal 'foo', model.primary_key assert_equal 'foo', model.primary_key


ActiveRecord::Base.establish_connection(connection) ActiveRecord::Model.establish_connection(connection)


assert_equal 'foo', model.primary_key assert_equal 'foo', model.primary_key
end end
Expand Down

0 comments on commit f06074f

Please sign in to comment.