From d6584cc394b343e02a734f8fb5075b8ed8afdb12 Mon Sep 17 00:00:00 2001 From: Ben Mabey Date: Wed, 9 Jan 2013 14:18:08 -0700 Subject: [PATCH] rollback transaction records to deal with after_hook problems #99 --- lib/database_cleaner/active_record/transaction.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/database_cleaner/active_record/transaction.rb b/lib/database_cleaner/active_record/transaction.rb index 077b33c..d6c10bb 100644 --- a/lib/database_cleaner/active_record/transaction.rb +++ b/lib/database_cleaner/active_record/transaction.rb @@ -21,6 +21,11 @@ module DatabaseCleaner::ActiveRecord connection_class.connection.rollback_db_transaction + # The below is for handling after_commit hooks.. see https://github.com/bmabey/database_cleaner/issues/99 + if connection_class.connection.respond_to?(:rollback_transaction_records) + connection_class.connection.send(:rollback_transaction_records, true) + end + if connection_class.connection.respond_to?(:decrement_open_transactions) connection_class.connection.decrement_open_transactions else