diff options
author | Jon Leighton <j@jonathanleighton.com> | 2010-12-30 21:44:29 +0000 |
---|---|---|
committer | Jon Leighton <j@jonathanleighton.com> | 2010-12-31 20:00:44 +0000 |
commit | 2bf31868033c50d71d6d68c1ddad67147908adc4 (patch) | |
tree | e3fb991c062c88de82b2c2cd7c628e47e182da11 /activerecord/test/cases | |
parent | f7a15d0e03dc173ab5f88773a97a3bf26d7b957e (diff) | |
download | rails-2bf31868033c50d71d6d68c1ddad67147908adc4.tar.gz rails-2bf31868033c50d71d6d68c1ddad67147908adc4.tar.bz2 rails-2bf31868033c50d71d6d68c1ddad67147908adc4.zip |
Verify that when has_many associated objects are destroyed via :dependent => :destroy, when the parent is destroyed, the callbacks are run
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r-- | activerecord/test/cases/associations/callbacks_test.rb | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/activerecord/test/cases/associations/callbacks_test.rb b/activerecord/test/cases/associations/callbacks_test.rb index 6a30e2905b..2d0d4541b4 100644 --- a/activerecord/test/cases/associations/callbacks_test.rb +++ b/activerecord/test/cases/associations/callbacks_test.rb @@ -3,6 +3,7 @@ require 'models/post' require 'models/author' require 'models/project' require 'models/developer' +require 'models/company' class AssociationCallbacksTest < ActiveRecord::TestCase fixtures :posts, :authors, :projects, :developers @@ -81,6 +82,14 @@ class AssociationCallbacksTest < ActiveRecord::TestCase assert_equal callback_log, jack.post_log end + def test_has_many_callbacks_for_destroy_on_parent + firm = Firm.create! :name => "Firm" + client = firm.clients.create! :name => "Client" + firm.destroy + + assert_equal ["before_remove#{client.id}", "after_remove#{client.id}"], firm.log + end + def test_has_and_belongs_to_many_add_callback david = developers(:david) ar = projects(:active_record) |