aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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?