3 class MysqlConnectionTest
< ActiveRecord
::TestCase
6 @connection = ActiveRecord
::Base.connection
9 def test_mysql_reconnect_attribute_after_connection_with_reconnect_true
10 run_without_connection
do |orig_connection
|
11 ActiveRecord
::Base.establish_connection(orig_connection
.merge({:reconnect => true}))
12 assert ActiveRecord
::Base.connection
.raw_connection
.reconnect
16 def test_mysql_reconnect_attribute_after_connection_with_reconnect_false
17 run_without_connection
do |orig_connection
|
18 ActiveRecord
::Base.establish_connection(orig_connection
.merge({:reconnect => false}))
19 assert
!ActiveRecord
::Base.connection
.raw_connection
.reconnect
23 def test_no_automatic_reconnection_after_timeout
24 assert
@connection.active
?
25 @connection.update('set @@wait_timeout=1')
27 assert
!@connection.active
?
30 def test_successful_reconnection_after_timeout_with_manual_reconnect
31 assert
@connection.active
?
32 @connection.update('set @@wait_timeout=1')
34 @connection.reconnect
!
35 assert
@connection.active
?
38 def test_successful_reconnection_after_timeout_with_verify
39 assert
@connection.active
?
40 @connection.update('set @@wait_timeout=1')
43 assert
@connection.active
?
48 def run_without_connection
49 original_connection
= ActiveRecord
::Base.remove_connection
51 yield original_connection
53 ActiveRecord
::Base.establish_connection(original_connection
)