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

Use standard format_time with digest mailer

Oliver Günther873f9e8035a0
diff --git a/app/helpers/mail_digest_helper.rb b/app/helpers/mail_digest_helper.rb
index a449114a15a..7baebba824a 100644
--- a/app/helpers/mail_digest_helper.rb
+++ b/app/helpers/mail_digest_helper.rb
@@ -27,6 +27,8 @@
#++
module MailDigestHelper
+ include Redmine::I18n
+
def digest_summary_text(notification_count, mentioned_count)
mentioned = mentioned_count > 1 ? "plural" : "singular"
notifications = notification_count > 1 ? "plural" : "singular"
@@ -75,9 +77,7 @@ module MailDigestHelper
sanitize(
I18n.t(:"mail.work_packages.#{value}_at",
user:,
- timestamp: journal.created_at.strftime(
- "#{I18n.t(:"date.formats.default")}, #{I18n.t(:"time.formats.time")}"
- ))
+ timestamp: format_time(journal.created_at))
)
end
diff --git a/spec/mailers/digest_mailer_spec.rb b/spec/mailers/digest_mailer_spec.rb
index 10c1b341fa9..44aa78f1d00 100644
--- a/spec/mailers/digest_mailer_spec.rb
+++ b/spec/mailers/digest_mailer_spec.rb
@@ -102,7 +102,7 @@ RSpec.describe DigestMailer do
end
it "includes the notifications grouped by work package" do
- time_stamp = journal.created_at.strftime("%m/%d/%Y, %I:%M %p")
+ time_stamp = format_time(journal.created_at)
expect(mail_body)
.to have_text("Hello #{recipient.firstname}")
diff --git a/spec/mailers/previews/digest_mailer_preview.rb b/spec/mailers/previews/digest_mailer_preview.rb
index e43ee6ff0b3..816240ae23d 100644
--- a/spec/mailers/previews/digest_mailer_preview.rb
+++ b/spec/mailers/previews/digest_mailer_preview.rb
@@ -30,7 +30,7 @@ class DigestMailerPreview < ActionMailer::Preview
# Preview emails at http://localhost:3000/rails/mailers/digest_mailer
def work_packages
- notifications = Notification.where(resource_type: "WorkPackage")
+ notifications = Notification.where(resource_type: "WorkPackage").limit(10)
DigestMailer.work_packages(notifications.first.recipient_id, [notifications.ids])
end
end