aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Koziarski <michael@koziarski.com>2007-10-07 05:05:12 +0000
committerMichael Koziarski <michael@koziarski.com>2007-10-07 05:05:12 +0000
commitcd64471bdbac70e2505cca9acb622332ebd3a5f9 (patch)
tree92e63bf40b5f182b2e346c8ffa509dafdd8dce22
parent5a276643d163b675dea459071824deae3ebec9f2 (diff)
downloadrails-cd64471bdbac70e2505cca9acb622332ebd3a5f9.tar.gz
rails-cd64471bdbac70e2505cca9acb622332ebd3a5f9.tar.bz2
rails-cd64471bdbac70e2505cca9acb622332ebd3a5f9.zip
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
-rw-r--r--activerecord/CHANGELOG2
-rw-r--r--activerecord/lib/active_record/associations/association_collection.rb2
-rwxr-xr-xactiverecord/test/associations_test.rb3
3 files changed, 5 insertions, 2 deletions
diff --git a/activerecord/CHANGELOG b/activerecord/CHANGELOG
index c5b908b0e4..689575c2c6 100644
--- a/activerecord/CHANGELOG
+++ b/activerecord/CHANGELOG
@@ -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]
diff --git a/activerecord/lib/active_record/associations/association_collection.rb b/activerecord/lib/active_record/associations/association_collection.rb
index 66ee712d7d..5598d6daa7 100644
--- a/activerecord/lib/active_record/associations/association_collection.rb
+++ b/activerecord/lib/active_record/associations/association_collection.rb
@@ -67,7 +67,7 @@ module ActiveRecord
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
diff --git a/activerecord/test/associations_test.rb b/activerecord/test/associations_test.rb
index 85df401fb1..37e26ef80a 100755
--- a/activerecord/test/associations_test.rb
+++ b/activerecord/test/associations_test.rb
@@ -831,7 +831,8 @@ class HasManyAssociationsTest < Test::Unit::TestCase
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?