aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases
diff options
context:
space:
mode:
authorBrian Durand <brian@embellishedvisions.com>2010-06-18 16:59:33 -0500
committerJeremy Kemper <jeremy@bitsweat.net>2010-06-18 15:11:17 -0700
commit237165feb3e5f7b117b05353bd64d756b9f18f74 (patch)
treef2da9c8c97555e849fe2978fb4a35e99f5b17513 /activerecord/test/cases
parenta186431414de8a0f0db9f60254f421a3536cee12 (diff)
downloadrails-237165feb3e5f7b117b05353bd64d756b9f18f74.tar.gz
rails-237165feb3e5f7b117b05353bd64d756b9f18f74.tar.bz2
rails-237165feb3e5f7b117b05353bd64d756b9f18f74.zip
Fix bug with rolling back frozen attributes.
[#2991] Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r--activerecord/test/cases/autosave_association_test.rb1
-rw-r--r--activerecord/test/cases/transaction_callbacks_test.rb14
2 files changed, 11 insertions, 4 deletions
diff --git a/activerecord/test/cases/autosave_association_test.rb b/activerecord/test/cases/autosave_association_test.rb
index 4e4f9c385c..3b89c12a3f 100644
--- a/activerecord/test/cases/autosave_association_test.rb
+++ b/activerecord/test/cases/autosave_association_test.rb
@@ -712,7 +712,6 @@ class TestDestroyAsPartOfAutosaveAssociation < ActiveRecord::TestCase
end
assert_raise(RuntimeError) { assert !@pirate.save }
- assert before.first.frozen? # the first child was indeed destroyed
assert_equal before, @pirate.reload.send(association_name)
end
diff --git a/activerecord/test/cases/transaction_callbacks_test.rb b/activerecord/test/cases/transaction_callbacks_test.rb
index ebc16653cb..df123c9de8 100644
--- a/activerecord/test/cases/transaction_callbacks_test.rb
+++ b/activerecord/test/cases/transaction_callbacks_test.rb
@@ -221,20 +221,28 @@ class TransactionCallbacksTest < ActiveRecord::TestCase
assert_equal 2, @first.rollbacks
end
- def test_after_transaction_callbacks_should_not_raise_errors
+ def test_after_transaction_callbacks_should_prevent_callbacks_from_being_called
def @first.last_after_transaction_error=(e); @last_transaction_error = e; end
def @first.last_after_transaction_error; @last_transaction_error; end
@first.after_commit_block{|r| r.last_after_transaction_error = :commit; raise "fail!";}
@first.after_rollback_block{|r| r.last_after_transaction_error = :rollback; raise "fail!";}
+ @second.after_commit_block{|r| r.history << :after_commit}
+ @second.after_rollback_block{|r| r.history << :after_rollback}
- @first.save!
+ Topic.transaction do
+ @first.save!
+ @second.save!
+ end
assert_equal :commit, @first.last_after_transaction_error
+ assert_equal [:after_commit], @second.history
+ @second.history.clear
Topic.transaction do
@first.save!
+ @second.save!
raise ActiveRecord::Rollback
end
-
assert_equal :rollback, @first.last_after_transaction_error
+ assert_equal [:after_rollback], @second.history
end
end