mirror of
https://github.com/discourse/discourse.git
synced 2025-04-27 23:14:37 +08:00
FIX: summary email excludes all untagged topics if user has muted some tags
This commit is contained in:
parent
35ff5d6796
commit
3964929c75
@ -373,7 +373,7 @@ class Topic < ActiveRecord::Base
|
|||||||
muted_tag_ids = TagUser.lookup(user, :muted).pluck(:tag_id)
|
muted_tag_ids = TagUser.lookup(user, :muted).pluck(:tag_id)
|
||||||
unless muted_tag_ids.empty?
|
unless muted_tag_ids.empty?
|
||||||
topics = topics.joins("LEFT OUTER JOIN topic_tags ON topic_tags.topic_id = topics.id")
|
topics = topics.joins("LEFT OUTER JOIN topic_tags ON topic_tags.topic_id = topics.id")
|
||||||
.where("topic_tags.tag_id NOT IN (?)", muted_tag_ids)
|
.where("topic_tags.tag_id NOT IN (?) OR topic_tags.tag_id is null", muted_tag_ids)
|
||||||
end
|
end
|
||||||
|
|
||||||
topics
|
topics
|
||||||
|
@ -1413,6 +1413,17 @@ describe Topic do
|
|||||||
expect(Topic.for_digest(user, 1.year.ago, top_order: true)).to eq([topic])
|
expect(Topic.for_digest(user, 1.year.ago, top_order: true)).to eq([topic])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "returns topics with no tags too" do
|
||||||
|
user = Fabricate(:user)
|
||||||
|
muted_tag, other_tag = Fabricate(:tag), Fabricate(:tag)
|
||||||
|
TagUser.change(user.id, muted_tag.id, TagUser.notification_levels[:muted])
|
||||||
|
topic1 = Fabricate(:topic, tags: [muted_tag])
|
||||||
|
topic2 = Fabricate(:topic, tags: [other_tag])
|
||||||
|
topic3 = Fabricate(:topic)
|
||||||
|
|
||||||
|
expect(Topic.for_digest(user, 1.year.ago, top_order: true)).to contain_exactly(topic2, topic3)
|
||||||
|
end
|
||||||
|
|
||||||
it "sorts by category notification levels" do
|
it "sorts by category notification levels" do
|
||||||
category1, category2 = Fabricate(:category), Fabricate(:category)
|
category1, category2 = Fabricate(:category), Fabricate(:category)
|
||||||
2.times {|i| Fabricate(:topic, category: category1) }
|
2.times {|i| Fabricate(:topic, category: category1) }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user