From 6d122d7f5e7fdd6fb5e44160fe1946ff0e7c2b93 Mon Sep 17 00:00:00 2001 From: Carl Porth Date: Tue, 27 May 2008 21:48:04 -0700 Subject: [PATCH] Added an additional record to TransactionTest#test_callback_rollback_in_create to reveal that the new_record attribute is not getting rolled back. --- activerecord/test/cases/transactions_test.rb | 18 ++++++++++++++++++ 1 files changed, 18 insertions(+), 0 deletions(-) diff --git a/activerecord/test/cases/transactions_test.rb b/activerecord/test/cases/transactions_test.rb index 06a76ea..49ef771 100644 --- a/activerecord/test/cases/transactions_test.rb +++ b/activerecord/test/cases/transactions_test.rb @@ -116,9 +116,24 @@ class TransactionTest < ActiveRecord::TestCase id_present = new_topic.has_attribute?(Topic.primary_key) id_snapshot = new_topic.id + new_topic_2 = Topic.new( + :title => "A new topic", + :author_name => "Carl", + :author_email_address => "ben@example.com", + :written_on => "2003-07-16t15:28:11.2233+01:00", + :last_read => "2004-04-15", + :bonus_time => "2005-01-30t15:28:00.00+01:00", + :content => "Have a really nice day", + :approved => false) + new_record_2_snapshot = new_topic_2.new_record? + id_present_2 = new_topic_2.has_attribute?(Topic.primary_key) + id_snapshot_2 = new_topic_2.id + # Make sure the second save gets the after_create callback called. 2.times do begin + new_topic_2.approved = true + new_topic_2.save add_exception_raising_after_create_callback_to_topic new_topic.approved = true new_topic.save @@ -128,6 +143,9 @@ class TransactionTest < ActiveRecord::TestCase assert_equal new_record_snapshot, new_topic.new_record?, "The topic should have its old new_record value" assert_equal id_snapshot, new_topic.id, "The topic should have its old id" assert_equal id_present, new_topic.has_attribute?(Topic.primary_key) + assert_equal new_record_2_snapshot, new_topic_2.new_record?, "The topic should have its old new_record value" + assert_equal id_snapshot_2, new_topic_2.id, "The topic should have its old id" + assert_equal id_present_2, new_topic_2.has_attribute?(Topic.primary_key) ensure remove_exception_raising_after_create_callback_to_topic end -- 1.5.5.1