aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test
diff options
context:
space:
mode:
authorJon Leighton <j@jonathanleighton.com>2010-12-30 20:41:02 +0000
committerJon Leighton <j@jonathanleighton.com>2010-12-31 20:00:44 +0000
commit38fbfa6390c449dfc9a3db2975e65bd0fd665b18 (patch)
treeea2a47a03413d39eec1f5a2d8eb87cec71af0d87 /activerecord/test
parent27ea0481bb68b2a09ade4f442beea3eac812b72c (diff)
downloadrails-38fbfa6390c449dfc9a3db2975e65bd0fd665b18.tar.gz
rails-38fbfa6390c449dfc9a3db2975e65bd0fd665b18.tar.bz2
rails-38fbfa6390c449dfc9a3db2975e65bd0fd665b18.zip
Refactor configure_dependency_for_has_many to use AssociationCollection#delete_all. It was necessary to change test_before_destroy in lifecycle_test.rb so that it checks topic.replies.size *before* doing the destroy, as afterwards it will now (correctly) be 0.
Diffstat (limited to 'activerecord/test')
-rw-r--r--activerecord/test/cases/lifecycle_test.rb7
1 files changed, 4 insertions, 3 deletions
diff --git a/activerecord/test/cases/lifecycle_test.rb b/activerecord/test/cases/lifecycle_test.rb
index b8c3ffb9cb..0558deb71b 100644
--- a/activerecord/test/cases/lifecycle_test.rb
+++ b/activerecord/test/cases/lifecycle_test.rb
@@ -101,9 +101,10 @@ class LifecycleTest < ActiveRecord::TestCase
fixtures :topics, :developers, :minimalistics
def test_before_destroy
- original_count = Topic.count
- (topic_to_be_destroyed = Topic.find(1)).destroy
- assert_equal original_count - (1 + topic_to_be_destroyed.replies.size), Topic.count
+ topic = Topic.find(1)
+ assert_difference 'Topic.count', -(1 + topic.replies.size) do
+ topic.destroy
+ end
end
def test_auto_observer