Fix calling .clear on a has_many :dependent=>:delete_all association. [tarmo] Closes #6904

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7767 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
Michael Koziarski 2007-10-07 05:05:12 +00:00
parent 5a276643d1
commit cd64471bdb
3 changed files with 5 additions and 2 deletions

@ -1,5 +1,7 @@
*SVN*
* Fix calling .clear on a has_many :dependent=>:delete_all association. [tarmo]
* Allow change_column to set NOT NULL in the PostgreSQL adapter [tarmo]
* Fix that ActiveRecord would create attribute methods and override custom attribute getters if the method is also defined in Kernel.methods. [Rick]

@ -67,7 +67,7 @@ def delete(*records)
def clear
return self if length.zero? # forces load_target if it hasn't happened already
if @reflection.options[:dependent] && @reflection.options[:dependent] == :delete_all
if @reflection.options[:dependent] && @reflection.options[:dependent] == :destroy
destroy_all
else
delete_all

@ -831,7 +831,8 @@ def test_clearing_an_exclusively_dependent_association_collection
assert_equal 0, firm.exclusively_dependent_clients_of_firm.size
assert_equal 0, firm.exclusively_dependent_clients_of_firm(true).size
assert_equal [3], Client.destroyed_client_ids[firm.id]
# no destroy-filters should have been called
assert_equal [], Client.destroyed_client_ids[firm.id]
# Should be destroyed since the association is exclusively dependent.
assert Client.find_by_id(client_id).nil?