From 0355962c277e8fe696f5568037b5804d014cb1fe Mon Sep 17 00:00:00 2001 From: wangjohn Date: Sun, 20 Jan 2013 12:40:36 -0500 Subject: Created state for a transaction and added tests. --- activerecord/test/cases/transactions_test.rb | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'activerecord/test') diff --git a/activerecord/test/cases/transactions_test.rb b/activerecord/test/cases/transactions_test.rb index bcbc48b38a..9d278480ef 100644 --- a/activerecord/test/cases/transactions_test.rb +++ b/activerecord/test/cases/transactions_test.rb @@ -451,6 +451,26 @@ class TransactionTest < ActiveRecord::TestCase end end + def test_transactions_state_from_rollback + connection = Topic.connection + transaction = ActiveRecord::ConnectionAdapters::ClosedTransaction.new(connection).begin + + assert transaction.open? + transaction.perform_rollback + + assert transaction.rolledback? + end + + def test_transactions_state_from_commit + connection = Topic.connection + transaction = ActiveRecord::ConnectionAdapters::ClosedTransaction.new(connection).begin + + assert transaction.open? + transaction.perform_commit + + assert transaction.committed? + end + private %w(validation save destroy).each do |filter| -- cgit v1.2.3