aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases
diff options
context:
space:
mode:
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r--activerecord/test/cases/transactions_test.rb56
1 files changed, 56 insertions, 0 deletions
diff --git a/activerecord/test/cases/transactions_test.rb b/activerecord/test/cases/transactions_test.rb
index e6ed85394b..bb5548a60f 100644
--- a/activerecord/test/cases/transactions_test.rb
+++ b/activerecord/test/cases/transactions_test.rb
@@ -274,6 +274,62 @@ class TransactionTest < ActiveRecord::TestCase
end
end
+ def test_dirty_state_rollback
+ assert !@first.approved?
+ Topic.transaction do
+ @first.approved = true
+ @first.save!
+ raise ActiveRecord::Rollback
+ end
+ assert @first.approved
+ assert @first.changes["approved"]
+ @first.save!
+ assert @first.reload.approved
+ end
+
+ def test_dirty_state_rollback2
+ assert !@first.approved?
+ @first.approved = true
+ Topic.transaction do
+ @first.save!
+ raise ActiveRecord::Rollback
+ end
+ assert @first.changes["approved"]
+ assert @first.approved
+ @first.save!
+ assert @first.reload.approved
+ end
+
+ def test_dirty_state_rollback3
+ assert !@first.approved?
+ @first.approved = true
+ @first.save!
+ Topic.transaction do
+ @first.approved = false
+ @first.save!
+ raise ActiveRecord::Rollback
+ end
+ assert !@first.approved
+ assert @first.changes["approved"]
+ @first.save!
+ assert !@first.reload.approved
+ end
+
+ def test_dirty_state_rollback4
+ assert !@first.approved?
+ Topic.transaction do
+ @first.approved = true
+ @first.save!
+ @first.approved = false
+ @first.save!
+ raise ActiveRecord::Rollback
+ end
+ assert !@first.approved
+ assert !@first.changes["approved"]
+ @first.save!
+ assert !@first.reload.approved
+ end
+
def test_force_savepoint_in_nested_transaction
Topic.transaction do
@first.approved = true