1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

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.
This commit is contained in:
Dylan Thacker-Smith 2017-01-09 14:34:18 -05:00
parent 3bc747bd86
commit a01a3fa608

View file

@ -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