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

implementation/60342 Update reminder email subject to include the note (#17504)

Kabiru Mwenja0d7ebce60397
diff --git a/app/mailers/reminders/notification_mailer.rb b/app/mailers/reminders/notification_mailer.rb
index 079d71e1559..e193727ebef 100644
--- a/app/mailers/reminders/notification_mailer.rb
+++ b/app/mailers/reminders/notification_mailer.rb
@@ -33,24 +33,33 @@ class Reminders::NotificationMailer < ApplicationMailer
helper :mail_notification
helper_method :reminder_summary_text,
:reminder_timestamp_text,
- :reminder_note_text
+ :reminder_note_text,
+ :work_package_subject_text_wrapper,
+ :text_email_wrapper
def reminder_notification(notification)
@notification = notification
@user = notification.recipient
+ @work_package = notification.resource
+ @reminder = notification.reminder
open_project_headers User: notification.recipient.name
message_id "reminder", notification.recipient
send_localized_mail(notification.recipient) do
- "#{Setting.app_title} - #{reminder_summary_text}"
+ "#{Setting.app_title} - #{email_subject_suffix}"
end
end
private
+ def email_subject_suffix
+ note = @reminder.note.presence || @work_package.subject
+ I18n.t(:"mail.reminder_notifications.subject", note:)
+ end
+
def reminder_summary_text
- I18n.t(:"mail.reminder_notifications.subject")
+ I18n.t(:"mail.reminder_notifications.heading")
end
def reminder_timestamp_text
@@ -58,8 +67,16 @@ class Reminders::NotificationMailer < ApplicationMailer
end
def reminder_note_text
- return if @notification.reminder.note.blank?
+ return if @reminder.note.blank?
+
+ I18n.t(:"mail.reminder_notifications.note", note: @reminder.note)
+ end
+
+ def work_package_subject_text_wrapper
+ "=" * ("# #{@work_package.id}#{@work_package.subject}".length + 4)
+ end
- I18n.t(:"mail.reminder_notifications.note", note: @notification.reminder.note)
+ def text_email_wrapper
+ "-" * 100
end
end
diff --git a/app/views/reminders/notification_mailer/reminder_notification.text.erb b/app/views/reminders/notification_mailer/reminder_notification.text.erb
index b48361bb643..8a945818408 100644
--- a/app/views/reminders/notification_mailer/reminder_notification.text.erb
+++ b/app/views/reminders/notification_mailer/reminder_notification.text.erb
@@ -1,14 +1,12 @@
<%= I18n.t(:'mail.salutation', user: @user.firstname) %>
<%= reminder_summary_text %>
-<%= "-" * 100 %>
+<%= text_email_wrapper %>
-<% work_package = @notification.resource %>
-
-<%= "=" * (('# ' + work_package.id.to_s + work_package.subject).length + 4) %>
-= #<%= work_package.id %> <%= work_package.subject %> =
-<%= "=" * (('# ' + work_package.id.to_s + work_package.subject).length + 4) %>
+<%= work_package_subject_text_wrapper %>
+= #<%= @work_package.id %> <%= @work_package.subject %> =
+<%= work_package_subject_text_wrapper %>
<%= reminder_timestamp_text %>
<%= reminder_note_text %>
-<%= "-" * 100 %>
+<%= text_email_wrapper %>
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 1ad676c1648..9a4dc283388 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -2990,7 +2990,8 @@ en:
see_all: "See all"
updated_at: "Updated at %{timestamp} by %{user}"
reminder_notifications:
- subject: "You have a new reminder"
+ subject: "Reminder: %{note}"
+ heading: "You have a new reminder"
note: "Note: “%{note}”"
sharing:
work_packages:
diff --git a/spec/mailers/reminders/notification_mailer_spec.rb b/spec/mailers/reminders/notification_mailer_spec.rb
index a7ac45875fe..bc220220472 100644
--- a/spec/mailers/reminders/notification_mailer_spec.rb
+++ b/spec/mailers/reminders/notification_mailer_spec.rb
@@ -43,8 +43,22 @@ RSpec.describe Reminders::NotificationMailer do
let(:mail_body) { mail.body.parts.detect { |part| part["Content-Type"].value == "text/html" }.body.to_s }
- it "notes reminder in subject" do
- expect(mail.subject).to eql("OpenProject - You have a new reminder")
+ describe "Email subject" do
+ context "when the reminder has a note" do
+ it "includes the note" do
+ expect(mail.subject).to eql("OpenProject - Reminder: This is an important reminder")
+ end
+ end
+
+ context "when the reminder does not have a note" do
+ before do
+ notification.reminder.note = ""
+ end
+
+ it "includes the work package subject" do
+ expect(mail.subject).to eql("OpenProject - Reminder: #{work_package.subject}")
+ end
+ end
end
it "sends to the recipient" do