aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/associations/callbacks_test.rb
diff options
context:
space:
mode:
authorMichael Koziarski <michael@koziarski.com>2008-04-04 14:37:22 +0000
committerMichael Koziarski <michael@koziarski.com>2008-04-04 14:37:22 +0000
commit36b8073ff553e8939d78ca2371ffdec7eb8f8071 (patch)
treedb61c081ffdbc5ae43426dbad23d5baa5bd2daf7 /activerecord/test/cases/associations/callbacks_test.rb
parent50538fb524950798cd8896f693909bdbc620bd8e (diff)
downloadrails-36b8073ff553e8939d78ca2371ffdec7eb8f8071.tar.gz
rails-36b8073ff553e8939d78ca2371ffdec7eb8f8071.tar.bz2
rails-36b8073ff553e8939d78ca2371ffdec7eb8f8071.zip
Make HABTM#create behave the same as << with after_add callbacks. Closes #11374 [freels]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@9224 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/test/cases/associations/callbacks_test.rb')
-rw-r--r--activerecord/test/cases/associations/callbacks_test.rb15
1 files changed, 15 insertions, 0 deletions
diff --git a/activerecord/test/cases/associations/callbacks_test.rb b/activerecord/test/cases/associations/callbacks_test.rb
index 17188e0b79..91b1af125e 100644
--- a/activerecord/test/cases/associations/callbacks_test.rb
+++ b/activerecord/test/cases/associations/callbacks_test.rb
@@ -94,6 +94,21 @@ class AssociationCallbacksTest < ActiveRecord::TestCase
"after_adding#{david.id}"], ar.developers_log
end
+ def test_has_and_belongs_to_many_after_add_called_after_save
+ ar = projects(:active_record)
+ assert ar.developers_log.empty?
+ alice = Developer.new(:name => 'alice')
+ ar.developers_with_callbacks << alice
+ assert_equal"after_adding#{alice.id}", ar.developers_log.last
+
+ bob = ar.developers_with_callbacks.create(:name => 'bob')
+ assert_equal "after_adding#{bob.id}", ar.developers_log.last
+
+ ar.developers_with_callbacks.build(:name => 'charlie')
+ assert_equal "after_adding<new>", ar.developers_log.last
+ end
+
+
def test_has_and_belongs_to_many_remove_callback
david = developers(:david)
jamis = developers(:jamis)