Skip to content

Commit

Permalink
Revert "Fix: counter_cache should decrement on deleting associated re…
Browse files Browse the repository at this point in the history
…cords."

[#1196 state:open]

This reverts commit 757e436.
  • Loading branch information
jeremy committed Dec 10, 2008
1 parent 757e436 commit 5b29008
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,6 @@ def delete(*records)

records.each do |record|
@target.delete(record)
if respond_to?(:cached_counter_attribute_name) && @owner[cached_counter_attribute_name]
@owner.class.decrement_counter(cached_counter_attribute_name, @owner.send(@owner.class.primary_key))
end
callback(:after_remove, record)
end
end
Expand Down
20 changes: 0 additions & 20 deletions activerecord/test/cases/associations/has_many_associations_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -536,18 +536,6 @@ def test_deleting
assert_equal 0, companies(:first_firm).clients_of_firm(true).size
end

def test_deleting_updates_counter_cache
post = Post.first

post.comments.delete(post.comments.first)
post.reload
assert_equal post.comments(true).size, post.comments_count

post.comments.delete(post.comments.first)
post.reload
assert_equal 0, post.comments_count
end

def test_deleting_before_save
new_firm = Firm.new("name" => "A New Firm, Inc.")
new_client = new_firm.clients_of_firm.build("name" => "Another Client")
Expand Down Expand Up @@ -601,14 +589,6 @@ def test_clearing_an_association_collection
end
end

def test_clearing_updates_counter_cache
post = Post.first

post.comments.clear
post.reload
assert_equal 0, post.comments_count
end

def test_clearing_a_dependent_association_collection
firm = companies(:first_firm)
client_id = firm.dependent_clients_of_firm.first.id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@
require 'models/post'
require 'models/person'
require 'models/reader'
require 'models/comment'
require 'models/tag'
require 'models/tagging'
require 'models/author'

class HasManyThroughAssociationsTest < ActiveRecord::TestCase
fixtures :posts, :readers, :people
Expand Down Expand Up @@ -85,17 +81,6 @@ def test_delete_association
assert posts(:welcome).reload.people(true).empty?
end

def test_deleting_updates_counter_cache
taggable = Tagging.first.taggable
taggable.taggings.push(Tagging.new)
taggable.reload
assert_equal 1, taggable.taggings_count

taggable.taggings.delete(taggable.taggings.first)
taggable.reload
assert_equal 0, taggable.taggings_count
end

def test_replace_association
assert_queries(4){posts(:welcome);people(:david);people(:michael); posts(:welcome).people(true)}

Expand Down

0 comments on commit 5b29008

Please sign in to comment.