From a01a3fa608af19fff8e0491cd4e6ad18943c8010 Mon Sep 17 00:00:00 2001 From: Dylan Thacker-Smith Date: Mon, 9 Jan 2017 14:34:18 -0500 Subject: activerecord/test: Fix Mysql2ConnectionTest#test_execute_after_disconnect Mysql2ConnectionTest#test_execute_after_disconnect was originally added to catch a NoMethodError occuring in execute when the Mysql2Adapter has a nil `@connection`. Pull request #26869 removed the error message check in that test because the error message changed in the mysql2 gem, which caused the test to fail. Now the test wouldn't catch the original bug since the NoMethodError would get turned into a ActiveRecord::StatementInvalid exception. Check the cause of the StatementInvalid exception to make sure it is of the correct type. --- activerecord/test/cases/adapters/mysql2/connection_test.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'activerecord') diff --git a/activerecord/test/cases/adapters/mysql2/connection_test.rb b/activerecord/test/cases/adapters/mysql2/connection_test.rb index c1de2218e2..bae283a048 100644 --- a/activerecord/test/cases/adapters/mysql2/connection_test.rb +++ b/activerecord/test/cases/adapters/mysql2/connection_test.rb @@ -66,9 +66,10 @@ class Mysql2ConnectionTest < ActiveRecord::Mysql2TestCase def test_execute_after_disconnect @connection.disconnect! - assert_raise(ActiveRecord::StatementInvalid) do + error = assert_raise(ActiveRecord::StatementInvalid) do @connection.execute("SELECT 1") end + assert_kind_of Mysql2::Error, error.cause end def test_quote_after_disconnect -- cgit v1.2.3