@@ -1845,18 +1845,21 @@ class TransactionIsolationTest < ActiveRecord::TestCase
1845
1845
1846
1846
private
1847
1847
1848
- # Need to handle the resetting of the isolation level in the adapter by `SQLServerRealTransaction#commit`.
1849
- # MySQL & PostgreSQL do not reset the connection and SQLite does support transaction isolation. After that we
1850
- # can assert the number of expected isolation level events.
1848
+ # Need to handle the resetting of the isolation level in the adapter by `SQLServerRealTransaction#commit` for each
1849
+ # connection pool. After the resetting events have been removed we can assert the number of expected isolation level
1850
+ # events. This workaround assumes that the `count` also matches the number of connection pools used in the test.
1851
+ # Note: MySQL & PostgreSQL do not reset the connection and SQLite does support transaction isolation.
1851
1852
undef_method :assert_begin_isolation_level_event
1852
- def assert_begin_isolation_level_event ( events , isolation : "READ COMMITTED" )
1853
+ def assert_begin_isolation_level_event ( events , isolation : "READ COMMITTED" , count : 1 )
1853
1854
isolation_events = events . select { |event | event . match ( /SET TRANSACTION ISOLATION LEVEL/ ) }
1854
1855
1855
- index_of_reset_starting_isolation_level_event = isolation_events . index ( "SET TRANSACTION ISOLATION LEVEL READ COMMITTED" )
1856
- assert index_of_reset_starting_isolation_level_event . present?
1857
- isolation_events . delete_at ( index_of_reset_starting_isolation_level_event )
1856
+ count . times do
1857
+ index_of_reset_starting_isolation_level_event = isolation_events . index ( "SET TRANSACTION ISOLATION LEVEL READ COMMITTED" )
1858
+ assert index_of_reset_starting_isolation_level_event . present?
1859
+ isolation_events . delete_at ( index_of_reset_starting_isolation_level_event )
1860
+ end
1858
1861
1859
- assert_equal 1 , isolation_events . count { |event | event . match ( /SET TRANSACTION ISOLATION LEVEL #{ isolation } / ) }
1862
+ assert_equal count , isolation_events . count { |event | event . match ( /SET TRANSACTION ISOLATION LEVEL #{ isolation } / ) }
1860
1863
end
1861
1864
end
1862
1865
0 commit comments