mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: Muted tags are respected by TopicTrackingState (#8467)
When the tag is muted and topic contains that tag, we should not mark that message as NEW. There are 3 possible settings which site admin can set. remove_muted_tags_from_latest - always It means that if the topic got at least one muted tag, we should not mark that topic as NEW remove_muted_tags_from_latest - only muted Similar to above, however, if at least one tag is not muted, the topic is marked as NEW remove_muted_tags_from_latest - never Basically, mute tag setting is ignored and all topics are set as NEW
This commit is contained in:
committed by
GitHub
parent
6740e08caa
commit
81c7d6a462
@@ -353,6 +353,77 @@ describe TopicTrackingState do
|
||||
expect(report.length).to eq(1)
|
||||
end
|
||||
|
||||
context 'muted tags' do
|
||||
it "remove_muted_tags_from_latest is set to always" do
|
||||
SiteSetting.remove_muted_tags_from_latest = 'always'
|
||||
user = Fabricate(:user)
|
||||
tag1 = Fabricate(:tag)
|
||||
tag2 = Fabricate(:tag)
|
||||
Fabricate(:topic_tag, tag: tag1, topic: topic)
|
||||
Fabricate(:topic_tag, tag: tag2, topic: topic)
|
||||
post
|
||||
|
||||
report = TopicTrackingState.report(user)
|
||||
expect(report.length).to eq(1)
|
||||
|
||||
TagUser.create!(user_id: user.id,
|
||||
notification_level: TagUser.notification_levels[:muted],
|
||||
tag_id: tag1.id
|
||||
)
|
||||
|
||||
report = TopicTrackingState.report(user)
|
||||
expect(report.length).to eq(0)
|
||||
end
|
||||
|
||||
it "remove_muted_tags_from_latest is set to only_muted" do
|
||||
SiteSetting.remove_muted_tags_from_latest = 'only_muted'
|
||||
user = Fabricate(:user)
|
||||
tag1 = Fabricate(:tag)
|
||||
tag2 = Fabricate(:tag)
|
||||
Fabricate(:topic_tag, tag: tag1, topic: topic)
|
||||
Fabricate(:topic_tag, tag: tag2, topic: topic)
|
||||
post
|
||||
|
||||
report = TopicTrackingState.report(user)
|
||||
expect(report.length).to eq(1)
|
||||
|
||||
TagUser.create!(user_id: user.id,
|
||||
notification_level: TagUser.notification_levels[:muted],
|
||||
tag_id: tag1.id
|
||||
)
|
||||
|
||||
report = TopicTrackingState.report(user)
|
||||
expect(report.length).to eq(1)
|
||||
|
||||
TagUser.create!(user_id: user.id,
|
||||
notification_level: TagUser.notification_levels[:muted],
|
||||
tag_id: tag2.id
|
||||
)
|
||||
|
||||
report = TopicTrackingState.report(user)
|
||||
expect(report.length).to eq(0)
|
||||
end
|
||||
|
||||
it "remove_muted_tags_from_latest is set to never" do
|
||||
SiteSetting.remove_muted_tags_from_latest = 'never'
|
||||
user = Fabricate(:user)
|
||||
tag1 = Fabricate(:tag)
|
||||
Fabricate(:topic_tag, tag: tag1, topic: topic)
|
||||
post
|
||||
|
||||
report = TopicTrackingState.report(user)
|
||||
expect(report.length).to eq(1)
|
||||
|
||||
TagUser.create!(user_id: user.id,
|
||||
notification_level: TagUser.notification_levels[:muted],
|
||||
tag_id: tag1.id
|
||||
)
|
||||
|
||||
report = TopicTrackingState.report(user)
|
||||
expect(report.length).to eq(1)
|
||||
end
|
||||
end
|
||||
|
||||
it "correctly handles seen categories" do
|
||||
user = Fabricate(:user)
|
||||
post
|
||||
|
||||
@@ -68,6 +68,25 @@ RSpec.describe CurrentUserSerializer do
|
||||
end
|
||||
end
|
||||
|
||||
context "#muted_tag_ids" do
|
||||
fab!(:user) { Fabricate(:user) }
|
||||
fab!(:tag) { Fabricate(:tag) }
|
||||
let!(:tag_user) do
|
||||
TagUser.create!(user_id: user.id,
|
||||
notification_level: TagUser.notification_levels[:muted],
|
||||
tag_id: tag.id
|
||||
)
|
||||
end
|
||||
let :serializer do
|
||||
CurrentUserSerializer.new(user, scope: Guardian.new, root: false)
|
||||
end
|
||||
|
||||
it 'include muted tag ids' do
|
||||
payload = serializer.as_json
|
||||
expect(payload[:muted_tag_ids]).to eq([tag.id])
|
||||
end
|
||||
end
|
||||
|
||||
context "#second_factor_enabled" do
|
||||
fab!(:user) { Fabricate(:user) }
|
||||
let :serializer do
|
||||
|
||||
Reference in New Issue
Block a user