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

When visiting a tag page directly, we should display all topics, even if that tag is muted. This was not working for mixed-case tags.
This commit is contained in:
David Taylor 2020-07-20 11:01:29 +01:00 committed by GitHub
parent 9313706649
commit 5f3dfce4eb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 1 deletions

View File

@ -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'

View File

@ -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