FIX: Don't notify of pending flags if min_flags_staff_visibility not met

This commit is contained in:
Robin Ward 2019-01-22 11:01:18 -05:00
parent fc710de3ab
commit f32de88dfc
2 changed files with 17 additions and 8 deletions

View File

@ -15,7 +15,7 @@ module Jobs
flag_ids = pending_flag_ids
if flag_ids.size > 0 && last_notified_id.to_i < flag_ids.max
if flag_ids.size >= SiteSetting.min_flags_staff_visibility && last_notified_id.to_i < flag_ids.max
usernames = active_moderator_usernames
mentions = usernames.size > 0 ? "@#{usernames.join(', @')} " : ""

View File

@ -28,13 +28,6 @@ describe Jobs::PendingFlagsReminder do
described_class.new.execute({})
end
it "sends message when there is a flag older than 48 hours" do
Fabricate(:flag, created_at: 49.hours.ago)
PostAction.stubs(:flagged_posts_count).returns(1)
PostCreator.expects(:create).once.returns(true)
described_class.new.execute({})
end
it "doesn't send a message if there are no new flags older than 48 hours old" do
old_flag = Fabricate(:flag, created_at: 50.hours.ago)
new_flag = Fabricate(:flag, created_at: 47.hours.ago)
@ -45,5 +38,21 @@ describe Jobs::PendingFlagsReminder do
job.execute({})
expect(job.last_notified_id).to eq(old_flag.id)
end
it "doesn't send a message when min_flags_staff_visibility is not met" do
SiteSetting.min_flags_staff_visibility = 2
Fabricate(:flag, created_at: 49.hours.ago)
PostAction.stubs(:flagged_posts_count).returns(1)
PostCreator.expects(:create).never
described_class.new.execute({})
end
it "sends message when there is a flag older than 48 hours" do
Fabricate(:flag, created_at: 49.hours.ago)
PostAction.stubs(:flagged_posts_count).returns(1)
PostCreator.expects(:create).once.returns(true)
described_class.new.execute({})
end
end
end