Permalink
Browse files

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
  • Loading branch information...
1 parent 5a27664 commit cd64471bdbac70e2505cca9acb622332ebd3a5f9 @NZKoz NZKoz committed Oct 7, 2007
@@ -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?

0 comments on commit cd64471

Please sign in to comment.