FEATURE: allow user to override watched_precedence_over_muted setting (#22340)

Recently, site setting watched_precedence_over_muted was introduced - https://github.com/discourse/discourse/pull/22252

In this PR, we are allowing users to override it. The option is only displayed when the user has watched categories and muted tags, or vice versa.
This commit is contained in:
Krzysztof Kotlarek
2023-07-04 15:08:29 +10:00
committed by GitHub
parent 82d6420e31
commit 134dcdd63a
14 changed files with 107 additions and 28 deletions

View File

@@ -1918,7 +1918,7 @@ RSpec.describe PostAlerter do
)
end
it "adds notification when watched_precedence_over_mute setting is true" do
it "adds notification when watched_precedence_over_muted setting is true" do
SiteSetting.watched_precedence_over_muted = true
expect {
PostAlerter.post_created(topic_with_muted_tag_and_watched_category.posts.first)
@@ -1928,7 +1928,18 @@ RSpec.describe PostAlerter do
}.to change { Notification.count }.by(1)
end
it "does not add notification when watched_precedence_over_mute setting is false" do
it "respects user option even if watched_precedence_over_muted site setting is true" do
SiteSetting.watched_precedence_over_muted = true
user.user_option.update!(watched_precedence_over_muted: false)
expect {
PostAlerter.post_created(topic_with_muted_tag_and_watched_category.posts.first)
}.not_to change { Notification.count }
expect {
PostAlerter.post_created(topic_with_muted_category_and_watched_tag.posts.first)
}.not_to change { Notification.count }
end
it "does not add notification when watched_precedence_over_muted setting is false" do
SiteSetting.watched_precedence_over_muted = false
expect {
PostAlerter.post_created(topic_with_muted_tag_and_watched_category.posts.first)
@@ -1940,6 +1951,17 @@ RSpec.describe PostAlerter do
Notification.count
}.by(1)
end
it "respects user option even if watched_precedence_over_muted site setting is false" do
SiteSetting.watched_precedence_over_muted = false
user.user_option.update!(watched_precedence_over_muted: true)
expect {
PostAlerter.post_created(topic_with_muted_tag_and_watched_category.posts.first)
}.to change { Notification.count }.by(1)
expect {
PostAlerter.post_created(topic_with_muted_category_and_watched_tag.posts.first)
}.to change { Notification.count }.by(1)
end
end
context "with on change" do