FIX: Include watched topics from muted categories in digests (#12602)
Topic that are muted or from muted categories are not included in digests, but non-muted topics from muted categories should be included.
This commit is contained in:
parent
34596beb52
commit
1682827f67
|
@ -506,7 +506,7 @@ class Topic < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
if remove_category_ids.present?
|
if remove_category_ids.present?
|
||||||
remove_category_ids.uniq!
|
remove_category_ids.uniq!
|
||||||
topics = topics.where("topics.category_id NOT IN (?)", remove_category_ids)
|
topics = topics.where("topic_users.notification_level != ? OR topics.category_id NOT IN (?)", TopicUser.notification_levels[:muted], remove_category_ids)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Remove muted tags
|
# Remove muted tags
|
||||||
|
|
|
@ -1952,6 +1952,17 @@ describe Topic do
|
||||||
expect(Topic.for_digest(user, 1.year.ago)).to eq([])
|
expect(Topic.for_digest(user, 1.year.ago)).to eq([])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "does return watched topics from muted categories" do
|
||||||
|
user = Fabricate(:user)
|
||||||
|
category = Fabricate(:category_with_definition, created_at: 2.minutes.ago)
|
||||||
|
topic = Fabricate(:topic, category: category, created_at: 1.minute.ago)
|
||||||
|
|
||||||
|
CategoryUser.set_notification_level_for_category(user, CategoryUser.notification_levels[:muted], category.id)
|
||||||
|
Fabricate(:topic_user, user: user, topic: topic, notification_level: TopicUser.notification_levels[:regular])
|
||||||
|
|
||||||
|
expect(Topic.for_digest(user, 1.year.ago, top_order: true)).to eq([topic])
|
||||||
|
end
|
||||||
|
|
||||||
it "doesn't return topics from suppressed categories" do
|
it "doesn't return topics from suppressed categories" do
|
||||||
user = Fabricate(:user)
|
user = Fabricate(:user)
|
||||||
category = Fabricate(:category_with_definition, created_at: 2.minutes.ago)
|
category = Fabricate(:category_with_definition, created_at: 2.minutes.ago)
|
||||||
|
|
Loading…
Reference in New Issue