FEATURE: Digest suppression by tags (#23089)

* FEATURE: Digest suppression by tags

* fixed stree issues

* fixed code so untagged topics are not suppressed when suppressing certain tags
This commit is contained in:
Juan David Martínez Cubillos
2023-08-18 14:28:20 -05:00
committed by GitHub
parent 3d86fc1391
commit 477a5dd371
4 changed files with 32 additions and 0 deletions

View File

@@ -2363,6 +2363,27 @@ RSpec.describe Topic do
expect(Topic.for_digest(user, 1.year.ago, top_order: true)).to be_blank
end
it "doesn't return topics from suppressed tags" do
category = Fabricate(:category_with_definition, created_at: 2.minutes.ago)
topic = Fabricate(:topic, category: category, created_at: 1.minute.ago)
topic2 = Fabricate(:topic, category: category, created_at: 1.minute.ago)
tag = Fabricate(:tag)
Fabricate(:topic_tag, topic: topic, tag: tag)
SiteSetting.digest_suppress_tags = "#{tag.id}"
topics = Topic.for_digest(user, 1.year.ago, top_order: true)
expect(topics).to eq([topic2])
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([topic2])
end
it "doesn't return topics from TL0 users" do
new_user = Fabricate(:user, trust_level: 0)
Fabricate(:topic, user: new_user, created_at: 1.minute.ago)