aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/association_callbacks_test.rb
diff options
context:
space:
mode:
authorTobias Lütke <tobias.luetke@gmail.com>2005-10-14 12:53:39 +0000
committerTobias Lütke <tobias.luetke@gmail.com>2005-10-14 12:53:39 +0000
commit5fa8793f02b58509a90eed69e8dc3d199f89b4ad (patch)
treeb00feb5e67e67c43b20c600ad7bc62dfd98243be /activerecord/test/association_callbacks_test.rb
parent4a1ed01e9d53da87b57802cb99e3ca7956a6eef7 (diff)
downloadrails-5fa8793f02b58509a90eed69e8dc3d199f89b4ad.tar.gz
rails-5fa8793f02b58509a90eed69e8dc3d199f89b4ad.tar.bz2
rails-5fa8793f02b58509a90eed69e8dc3d199f89b4ad.zip
DRYed up Associations#clear. Closes #1906 [Caleb]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2580 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/test/association_callbacks_test.rb')
-rw-r--r--activerecord/test/association_callbacks_test.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/activerecord/test/association_callbacks_test.rb b/activerecord/test/association_callbacks_test.rb
index 5ea1f541ed..1426fb71a9 100644
--- a/activerecord/test/association_callbacks_test.rb
+++ b/activerecord/test/association_callbacks_test.rb
@@ -83,6 +83,20 @@ class AssociationCallbacksTest < Test::Unit::TestCase
assert_equal ["before_removing#{david.id}", "after_removing#{david.id}", "before_removing#{jamis.id}",
"after_removing#{jamis.id}"], activerecord.developers_log
end
+
+ def test_has_and_belongs_to_many_remove_callback_on_clear
+ activerecord = projects(:active_record)
+ assert activerecord.developers_log.empty?
+ if activerecord.developers_with_callbacks.size == 0
+ activerecord.developers << developers(:david)
+ activerecord.developers << developers(:jamis)
+ activerecord.reload
+ assert activerecord.developers_with_callbacks.size == 2
+ end
+ log_array = activerecord.developers_with_callbacks.collect {|d| ["before_removing#{d.id}","after_removing#{d.id}"]}.flatten.sort
+ assert activerecord.developers_with_callbacks.clear
+ assert_equal log_array, activerecord.developers_log.sort
+ end
def test_dont_add_if_before_callback_raises_exception
assert !@david.unchangable_posts.include?(@authorless)