diff options
author | Florian Weber <csshsh@gmail.com> | 2006-04-03 22:37:56 +0000 |
---|---|---|
committer | Florian Weber <csshsh@gmail.com> | 2006-04-03 22:37:56 +0000 |
commit | bb4c6797bf83a7f31b490e3172fd8e17c2c6ca5a (patch) | |
tree | 9684ce5072516735eec31b18c3f7656f0abbf1bf /activerecord/test/associations_test.rb | |
parent | 109c56df3afdae0235757edad885b829b4b8a716 (diff) | |
download | rails-bb4c6797bf83a7f31b490e3172fd8e17c2c6ca5a.tar.gz rails-bb4c6797bf83a7f31b490e3172fd8e17c2c6ca5a.tar.bz2 rails-bb4c6797bf83a7f31b490e3172fd8e17c2c6ca5a.zip |
Fixed that AssociationCollection#delete_all should work even if the records of the association are not loaded yet. [Florian Weber]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4144 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/test/associations_test.rb')
-rwxr-xr-x | activerecord/test/associations_test.rb | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/activerecord/test/associations_test.rb b/activerecord/test/associations_test.rb index b87089b8ec..173808c370 100755 --- a/activerecord/test/associations_test.rb +++ b/activerecord/test/associations_test.rb @@ -550,6 +550,25 @@ class HasManyAssociationsTest < Test::Unit::TestCase assert_equal 0, companies(:first_firm).clients_of_firm.size assert_equal 0, companies(:first_firm).clients_of_firm(true).size end + + def test_delete_all + force_signal37_to_load_all_clients_of_firm + companies(:first_firm).clients_of_firm.create("name" => "Another Client") + assert_equal 2, companies(:first_firm).clients_of_firm.size + companies(:first_firm).clients_of_firm.delete_all + assert_equal 0, companies(:first_firm).clients_of_firm.size + assert_equal 0, companies(:first_firm).clients_of_firm(true).size + end + + def test_delete_all_with_not_yet_loaded_association_collection + force_signal37_to_load_all_clients_of_firm + companies(:first_firm).clients_of_firm.create("name" => "Another Client") + assert_equal 2, companies(:first_firm).clients_of_firm.size + companies(:first_firm).clients_of_firm.reset + companies(:first_firm).clients_of_firm.delete_all + assert_equal 0, companies(:first_firm).clients_of_firm.size + assert_equal 0, companies(:first_firm).clients_of_firm(true).size + end def test_clearing_an_association_collection firm = companies(:first_firm) |