Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Rename 'digest' to 'reminder', first chunk. Not touching Notification yet

Wieland Lindenthala701a6bdc20d
diff --git a/app/models/notification.rb b/app/models/notification.rb
index a0bc3c289c4..f6585e16cb3 100644
--- a/app/models/notification.rb
+++ b/app/models/notification.rb
@@ -22,7 +22,7 @@ class Notification < ApplicationRecord
belongs_to :resource, polymorphic: true
include Scopes::Scoped
- scopes :mail_digest_before,
+ scopes :unsent_reminders_before,
:unread_mail,
:unread_mail_digest,
:recipient
diff --git a/app/models/notifications/scopes/mail_digest_before.rb b/app/models/notifications/scopes/unsent_reminders_before.rb
similarity index 88%
rename from app/models/notifications/scopes/mail_digest_before.rb
rename to app/models/notifications/scopes/unsent_reminders_before.rb
index b20c706e4cc..e46f623164f 100644
--- a/app/models/notifications/scopes/mail_digest_before.rb
+++ b/app/models/notifications/scopes/unsent_reminders_before.rb
@@ -29,13 +29,13 @@
#++
module Notifications::Scopes
- module MailDigestBefore
+ module UnsentRemindersBefore
extend ActiveSupport::Concern
class_methods do
- # Return notifications of the user for which mail digest is to be sent and that is created before
+ # Return notifications for the user for who email reminders shall be sent and that were created before
# the specified time.
- def mail_digest_before(recipient:, time:)
+ def unsent_reminders_before(recipient:, time:)
where(Notification.arel_table[:created_at].lteq(time))
.where(recipient: recipient)
.where(read_mail_digest: false)
diff --git a/app/models/project.rb b/app/models/project.rb
index f663fb11733..8fa551314b4 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -44,7 +44,7 @@ class Project < ApplicationRecord
has_many :members, -> {
# TODO: check whether this should
- # remaint to be limited to User only
+ # remain to be limited to User only
includes(:principal, :roles)
.merge(Principal.not_locked.user)
.references(:principal, :roles)
diff --git a/app/workers/mails/digest_job.rb b/app/workers/mails/reminder_job.rb
similarity index 92%
rename from app/workers/mails/digest_job.rb
rename to app/workers/mails/reminder_job.rb
index ffa99c93b5e..fce4238e780 100644
--- a/app/workers/mails/digest_job.rb
+++ b/app/workers/mails/reminder_job.rb
@@ -28,13 +28,13 @@
# See COPYRIGHT and LICENSE files for more details.
#++
-class Mails::DigestJob < Mails::DeliverJob
+class Mails::ReminderJob < Mails::DeliverJob
private
def render_mail
# Have to cast to array since the update in the subsequent block
- # will result in the notification to not be found via the .mail_digest_before scope.
- notification_ids = Notification.mail_digest_before(recipient: recipient, time: Time.current).pluck(:id)
+ # will result in the notification to not be found via the .unsent_reminders_before scope.
+ notification_ids = Notification.unsent_reminders_before(recipient: recipient, time: Time.current).pluck(:id)
return nil if notification_ids.empty?
diff --git a/spec/models/notifications/scopes/mail_digest_before_spec.rb b/spec/models/notifications/scopes/unsent_reminders_before_spec.rb
similarity index 93%
rename from spec/models/notifications/scopes/mail_digest_before_spec.rb
rename to spec/models/notifications/scopes/unsent_reminders_before_spec.rb
index 70253d290a5..9e0f0a63fdf 100644
--- a/spec/models/notifications/scopes/mail_digest_before_spec.rb
+++ b/spec/models/notifications/scopes/unsent_reminders_before_spec.rb
@@ -28,9 +28,9 @@
require 'spec_helper'
-describe Notifications::Scopes::MailDigestBefore, type: :model do
- describe '.mail_digest_before' do
- subject(:scope) { ::Notification.mail_digest_before(recipient: recipient, time: time) }
+describe Notifications::Scopes::UnsentRemindersBefore, type: :model do
+ describe '.unsent_reminders_before' do
+ subject(:scope) { ::Notification.unsent_reminders_before(recipient: recipient, time: time) }
let(:recipient) do
FactoryBot.create(:user)
diff --git a/spec/workers/mails/digest_job_spec.rb b/spec/workers/mails/reminder_job_spec.rb
similarity index 97%
rename from spec/workers/mails/digest_job_spec.rb
rename to spec/workers/mails/reminder_job_spec.rb
index 6d3417febfd..2f7fd3d1dda 100644
--- a/spec/workers/mails/digest_job_spec.rb
+++ b/spec/workers/mails/reminder_job_spec.rb
@@ -30,7 +30,7 @@
require 'spec_helper'
-describe Mails::DigestJob, type: :model do
+describe Mails::ReminderJob, type: :model do
subject(:job) { described_class.perform_now(recipient) }
let(:recipient) do
@@ -46,7 +46,7 @@ describe Mails::DigestJob, type: :model do
.and_return(Time.current)
allow(Notification)
- .to receive(:mail_digest_before)
+ .to receive(:unsent_reminders_before)
.with(recipient: recipient, time: Time.current)
.and_return(notifications)