File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -1842,6 +1842,22 @@ class TransactionIsolationTest < ActiveRecord::TestCase
18421842
18431843 # I really need some help understanding this one.
18441844 coerce_tests! %r{repeatable read}
1845+
1846+ private
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.
1851+ undef_method :assert_begin_isolation_level_event
1852+ def assert_begin_isolation_level_event ( events , isolation : "READ COMMITTED" )
1853+ isolation_events = events . select { _1 . match ( /SET TRANSACTION ISOLATION LEVEL/ ) }
1854+
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 )
1858+
1859+ assert_equal 1 , isolation_events . select { _1 . match ( /SET TRANSACTION ISOLATION LEVEL #{ isolation } / ) } . size
1860+ end
18451861end
18461862
18471863class ViewWithPrimaryKeyTest < ActiveRecord ::TestCase
You can’t perform that action at this time.
0 commit comments