FIX: Respect muted tags for mailing list mode

If a user has a tag muted, don't send them emails about that tag.
We've done this forever for categories so it makes sense to do it
for tags too.
This commit is contained in:
Robin Ward
2020-02-19 15:14:42 -05:00
parent 223edd1286
commit 345764565f
2 changed files with 19 additions and 1 deletions

View File

@@ -7,9 +7,14 @@ describe Jobs::NotifyMailingListSubscribers do
fab!(:mailing_list_user) { Fabricate(:user) }
before { mailing_list_user.user_option.update(mailing_list_mode: true, mailing_list_mode_frequency: 1) }
before do
SiteSetting.tagging_enabled = true
end
fab!(:tag) { Fabricate(:tag) }
fab!(:topic) { Fabricate(:topic, tags: [tag]) }
fab!(:user) { Fabricate(:user) }
fab!(:post) { Fabricate(:post, user: user) }
fab!(:post) { Fabricate(:post, topic: topic, user: user) }
shared_examples "no emails" do
it "doesn't send any emails" do
@@ -127,6 +132,11 @@ describe Jobs::NotifyMailingListSubscribers do
include_examples "no emails"
end
context "from a muted tag" do
before { TagUser.create(user: mailing_list_user, tag: tag, notification_level: TagUser.notification_levels[:muted]) }
include_examples "no emails"
end
context "max emails per day was reached" do
before { SiteSetting.max_emails_per_day_per_user = 2 }