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:
parent
3bc747bd86
commit
a01a3fa608
1 changed files with 2 additions and 1 deletions
|
@ -66,9 +66,10 @@ class Mysql2ConnectionTest < ActiveRecord::Mysql2TestCase
|
||||||
def test_execute_after_disconnect
|
def test_execute_after_disconnect
|
||||||
@connection.disconnect!
|
@connection.disconnect!
|
||||||
|
|
||||||
assert_raise(ActiveRecord::StatementInvalid) do
|
error = assert_raise(ActiveRecord::StatementInvalid) do
|
||||||
@connection.execute("SELECT 1")
|
@connection.execute("SELECT 1")
|
||||||
end
|
end
|
||||||
|
assert_kind_of Mysql2::Error, error.cause
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_quote_after_disconnect
|
def test_quote_after_disconnect
|
||||||
|
|
Loading…
Reference in a new issue