diff --git a/app/jobs/scheduled/enqueue_reminders.rb b/app/jobs/scheduled/enqueue_reminders.rb index bead65c4..883a399d 100644 --- a/app/jobs/scheduled/enqueue_reminders.rb +++ b/app/jobs/scheduled/enqueue_reminders.rb @@ -22,6 +22,10 @@ def allowed_group_ids Group.assign_allowed_groups.pluck(:id).join(",") end + def reminder_threshold + @reminder_threshold ||= SiteSetting.pending_assign_reminder_threshold + end + def user_ids global_frequency = SiteSetting.remind_assigns_frequency frequency = @@ -54,7 +58,7 @@ def user_ids AND assignments.assigned_to_type = 'User' GROUP BY assignments.assigned_to_id - HAVING COUNT(assignments.assigned_to_id) > 1 + HAVING COUNT(assignments.assigned_to_id) >= #{reminder_threshold} SQL end end diff --git a/spec/jobs/scheduled/enqueue_reminders_spec.rb b/spec/jobs/scheduled/enqueue_reminders_spec.rb index 2c957b95..63d0173e 100644 --- a/spec/jobs/scheduled/enqueue_reminders_spec.rb +++ b/spec/jobs/scheduled/enqueue_reminders_spec.rb @@ -31,12 +31,20 @@ assert_reminders_enqueued(1) end - it "does not enqueue a reminder when the user only has one task" do + it "does not enqueue a reminder when the user has fewer assignments than `pending_assign_reminder_threshold`" do assign_one_task_to(user) assert_reminders_enqueued(0) end + it "enqueues a reminder when the user has one assignement if `pending_assign_reminder_threshold` is set to one" do + assign_one_task_to(user) + + SiteSetting.pending_assign_reminder_threshold = 1 + + assert_reminders_enqueued(1) + end + it "doesn't count assigns from deleted topics" do deleted_post = Fabricate(:post) assign_one_task_to(user, post: deleted_post)