A platform for community discussion. Free, open, simple.
FIX: synonym tags are not considered as unused (#23950)
Krzysztof Kotlarek09eca87c7643
diff --git a/app/models/tag.rb b/app/models/tag.rbindex a8205d0e88b..f33b6a47ba1 100644--- a/app/models/tag.rb+++ b/app/models/tag.rb@@ -30,7 +30,7 @@ class Tag < ActiveRecord::Base# tags that have never been used and don't belong to a tag groupscope :unused,-> {- where(staff_topic_count: 0, pm_topic_count: 0).joins(+ where(staff_topic_count: 0, pm_topic_count: 0, target_tag_id: nil).joins("LEFT JOIN tag_group_memberships tgm ON tags.id = tgm.tag_id",).where("tgm.tag_id IS NULL")}diff --git a/spec/models/tag_spec.rb b/spec/models/tag_spec.rbindex c1100d725e4..4437771c7b9 100644--- a/spec/models/tag_spec.rb+++ b/spec/models/tag_spec.rb@@ -299,6 +299,7 @@ RSpec.describe Tag do)endlet!(:tag_group) { Fabricate(:tag_group, tag_names: [tag_in_group.name]) }+ let!(:synonym_tag) { Fabricate(:tag, target_tag: tags.first) }it "returns the correct tags" doexpect(Tag.unused.pluck(:name)).to contain_exactly("unused1", "unused2")