diff options
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r-- | activerecord/test/cases/adapters/mysql/connection_test.rb | 26 | ||||
-rw-r--r-- | activerecord/test/cases/adapters/mysql2/connection_test.rb | 26 |
2 files changed, 52 insertions, 0 deletions
diff --git a/activerecord/test/cases/adapters/mysql/connection_test.rb b/activerecord/test/cases/adapters/mysql/connection_test.rb index 1844a2e0dc..ece0ee77fb 100644 --- a/activerecord/test/cases/adapters/mysql/connection_test.rb +++ b/activerecord/test/cases/adapters/mysql/connection_test.rb @@ -40,6 +40,11 @@ class MysqlConnectionTest < ActiveRecord::TestCase @connection.update('set @@wait_timeout=1') sleep 2 assert !@connection.active? + + # Repair all fixture connections so other tests won't break. + @fixture_connections.each do |c| + c.verify! + end end def test_successful_reconnection_after_timeout_with_manual_reconnect @@ -159,6 +164,27 @@ class MysqlConnectionTest < ActiveRecord::TestCase end end + def test_mysql_begin_db_transaction_can_throw_an_exception + @connection.expects(:exec_query).with('BEGIN').raises('OH NOES') + assert_raise RuntimeError do + @connection.begin_db_transaction + end + end + + def test_mysql_commit_db_transaction_can_throw_an_exception + @connection.expects(:execute).with('COMMIT').raises('OH NOES') + assert_raise RuntimeError do + @connection.commit_db_transaction + end + end + + def test_mysql_rollback_db_transaction_can_throw_an_exception + @connection.expects(:execute).with('ROLLBACK').raises('OH NOES') + assert_raise RuntimeError do + @connection.rollback_db_transaction + end + end + private def run_without_connection diff --git a/activerecord/test/cases/adapters/mysql2/connection_test.rb b/activerecord/test/cases/adapters/mysql2/connection_test.rb index 679c515e8c..943ca9d552 100644 --- a/activerecord/test/cases/adapters/mysql2/connection_test.rb +++ b/activerecord/test/cases/adapters/mysql2/connection_test.rb @@ -18,6 +18,11 @@ class MysqlConnectionTest < ActiveRecord::TestCase @connection.update('set @@wait_timeout=1') sleep 2 assert !@connection.active? + + # Repair all fixture connections so other tests won't break. + @fixture_connections.each do |c| + c.verify! + end end def test_successful_reconnection_after_timeout_with_manual_reconnect @@ -84,6 +89,27 @@ class MysqlConnectionTest < ActiveRecord::TestCase @connection.execute "DROP TABLE `bar_baz`" end + def test_mysql_begin_db_transaction_can_throw_an_exception + @connection.expects(:execute).with('BEGIN').raises('OH NOES') + assert_raise RuntimeError do + @connection.begin_db_transaction + end + end + + def test_mysql_commit_db_transaction_can_throw_an_exception + @connection.expects(:execute).with('COMMIT').raises('OH NOES') + assert_raise RuntimeError do + @connection.commit_db_transaction + end + end + + def test_mysql_rollback_db_transaction_can_throw_an_exception + @connection.expects(:execute).with('ROLLBACK').raises('OH NOES') + assert_raise RuntimeError do + @connection.rollback_db_transaction + end + end + private def run_without_connection |