A platform for community discussion. Free, open, simple.
FIX: Update tag topic counts when bulk removing tags (#32095)
Ted Johanssonb37591632db9
diff --git a/lib/topics_bulk_action.rb b/lib/topics_bulk_action.rbindex d7bcf4ba953..d639a734c47 100644--- a/lib/topics_bulk_action.rb+++ b/lib/topics_bulk_action.rb@@ -271,7 +271,7 @@ class TopicsBulkActiondef remove_tagstopics.each do |t|if guardian.can_edit?(t)- TopicTag.where(topic_id: t.id).delete_all+ TopicTag.where(topic_id: t.id).in_batches.destroy_all@changed_ids << t.idendenddiff --git a/spec/lib/topics_bulk_action_spec.rb b/spec/lib/topics_bulk_action_spec.rbindex 1c561d7259f..d5088cd44af 100644--- a/spec/lib/topics_bulk_action_spec.rb+++ b/spec/lib/topics_bulk_action_spec.rb@@ -558,15 +558,18 @@ RSpec.describe TopicsBulkAction dobefore doSiteSetting.tagging_enabled = trueSiteSetting.tag_topic_allowed_groups = Group::AUTO_GROUPS[:trust_level_0]- topic.tags = [tag1, tag2]+ TopicTag.create!(topic: topic, tag: tag1)+ TopicTag.create!(topic: topic, tag: tag2)endit "can remove all tags" do+ expect(tag1.reload.staff_topic_count).to eq(1)tba = TopicsBulkAction.new(topic.user, [topic.id], type: "remove_tags")topic_ids = tba.perform!expect(topic_ids).to eq([topic.id])topic.reloadexpect(topic.tags.size).to eq(0)+ expect(tag1.reload.staff_topic_count).to eq(0)endcontext "when user can't edit topic" do