Remove obsolete method to recalculate counter

This method isn't used since commit deffc7f8.
This commit is contained in:
Javi Martín
2019-10-22 20:51:06 +02:00
parent d29d5ede5a
commit 985eeca21e
2 changed files with 0 additions and 26 deletions

View File

@@ -63,12 +63,6 @@ module ActsAsTaggableOn
Tag.decrement_counter(custom_counter_field_name_for(taggable_type), id)
end
def recalculate_custom_counter_for(taggable_type)
visible_taggables = taggable_type.constantize.includes(:taggings).where("taggings.taggable_type" => taggable_type, "taggings.tag_id" => id)
update(custom_counter_field_name_for(taggable_type) => visible_taggables.count)
end
def self.category_names
Tag.category.pluck(:name)
end

View File

@@ -45,26 +45,6 @@ describe ActsAsTaggableOn do
end
describe "Tag" do
describe "#recalculate_custom_counter_for" do
it "updates the counters of proposals and debates, taking into account hidden ones" do
tag = Tag.create(name: "foo")
create(:proposal, tag_list: "foo")
create(:proposal, :hidden, tag_list: "foo")
create(:debate, tag_list: "foo")
create(:debate, :hidden, tag_list: "foo")
tag.update(debates_count: 0, proposals_count: 0)
tag.recalculate_custom_counter_for("Debate")
expect(tag.debates_count).to eq(1)
tag.recalculate_custom_counter_for("Proposal")
expect(tag.proposals_count).to eq(1)
end
end
describe "public_for_api scope" do
it "returns tags whose kind is NULL and have at least one tagging whose taggable is not hidden" do