1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
|
# frozen_string_literal: true
module TestProf
# Add missing `begin_transaction` and `rollback_transaction` methods
module ActiveRecord3Transactions
refine ::ActiveRecord::ConnectionAdapters::AbstractAdapter do
def begin_transaction(joinable: true)
if open_transactions > 0
increment_open_transactions
create_savepoint
else
begin_db_transaction
end
self.transaction_joinable = joinable
end
def rollback_transaction(*)
if open_transactions > 1
rollback_to_savepoint
else
rollback_db_transaction
end
decrement_open_transactions
end
end
end
end
|