Skip to content

A platform for community discussion. Free, open, simple.

FIX: Listing topics with muted mixed-case tags (#10268)

David Taylor5f3dfce4eb50
diff --git a/lib/topic_query.rb b/lib/topic_query.rb
index bf614e700ec..f030c83abae 100644
--- a/lib/topic_query.rb
+++ b/lib/topic_query.rb
@@ -890,7 +890,7 @@ class TopicQuery
# if viewing the topic list for a muted tag, show all the topics
if !opts[:no_tags] && opts[:tags].present?
- return list if TagUser.lookup(user, :muted).joins(:tag).where('tags.name = ?', opts[:tags].first).exists?
+ return list if TagUser.lookup(user, :muted).joins(:tag).where('lower(tags.name) = ?', opts[:tags].first.downcase).exists?
end
if SiteSetting.remove_muted_tags_from_latest == 'always'
diff --git a/spec/components/topic_query_spec.rb b/spec/components/topic_query_spec.rb
index d6e56a069de..6d97abfcb9c 100644
--- a/spec/components/topic_query_spec.rb
+++ b/spec/components/topic_query_spec.rb
@@ -362,6 +362,22 @@ describe TopicQuery do
topic_ids = topic_query.list_new.topics.map(&:id)
expect(topic_ids).to contain_exactly(muted_topic.id, tagged_topic.id, muted_tagged_topic.id, untagged_topic.id)
end
+
+ it 'is not removed from the tag page itself' do
+ muted_tag = Fabricate(:tag)
+ TagUser.create!(user_id: user.id,
+ tag_id: muted_tag.id,
+ notification_level: CategoryUser.notification_levels[:muted])
+
+ muted_topic = Fabricate(:topic, tags: [muted_tag])
+
+ topic_ids = topic_query.latest_results(tags: [muted_tag.name]).map(&:id)
+ expect(topic_ids).to contain_exactly(muted_topic.id)
+
+ muted_tag.update(name: "mixedCaseName")
+ topic_ids = topic_query.latest_results(tags: [muted_tag.name.downcase]).map(&:id)
+ expect(topic_ids).to contain_exactly(muted_topic.id)
+ end
end
context 'a bunch of topics' do