diff options
author | Matt Jones <al2o3cr@gmail.com> | 2009-11-07 14:00:54 -0500 |
---|---|---|
committer | Michael Koziarski <michael@koziarski.com> | 2009-11-10 18:41:37 +1300 |
commit | d625312fe11bbf53e285a0efd570249f0bf91fd1 (patch) | |
tree | 9ded25037ea44d55e11abb4e84a174694f99a350 /activerecord/test/cases/associations/has_many_associations_test.rb | |
parent | 11e798ae0f2f46498811282756c9d21df3d4b523 (diff) | |
download | rails-d625312fe11bbf53e285a0efd570249f0bf91fd1.tar.gz rails-d625312fe11bbf53e285a0efd570249f0bf91fd1.tar.bz2 rails-d625312fe11bbf53e285a0efd570249f0bf91fd1.zip |
delete correct records for a has_many with :primary_key and :dependent => :delete_all
Signed-off-by: Michael Koziarski <michael@koziarski.com>
Diffstat (limited to 'activerecord/test/cases/associations/has_many_associations_test.rb')
-rw-r--r-- | activerecord/test/cases/associations/has_many_associations_test.rb | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/activerecord/test/cases/associations/has_many_associations_test.rb b/activerecord/test/cases/associations/has_many_associations_test.rb index b193f8d8ba..86d14c9c81 100644 --- a/activerecord/test/cases/associations/has_many_associations_test.rb +++ b/activerecord/test/cases/associations/has_many_associations_test.rb @@ -659,6 +659,18 @@ class HasManyAssociationsTest < ActiveRecord::TestCase assert_equal 1, Client.find_all_by_client_of(firm.id).size end + def test_delete_all_association_with_primary_key_deletes_correct_records + firm = Firm.find(:first) + # break the vanilla firm_id foreign key + assert_equal 2, firm.clients.count + firm.clients.first.update_attribute(:firm_id, nil) + assert_equal 1, firm.clients(true).count + assert_equal 1, firm.clients_using_primary_key_with_delete_all.count + old_record = firm.clients_using_primary_key_with_delete_all.first + firm = Firm.find(:first) + firm.destroy + assert Client.find_by_id(old_record.id).nil? + end def test_creation_respects_hash_condition ms_client = companies(:first_firm).clients_like_ms_with_hash_conditions.build |