From 873f9e8035a0f35e7f0407cabe9f828af5b02e56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20G=C3=BCnther?= Date: Mon, 5 Aug 2024 14:28:54 +0200 Subject: [PATCH] Use standard format_time with digest mailer --- app/helpers/mail_digest_helper.rb | 6 +++--- spec/mailers/digest_mailer_spec.rb | 2 +- spec/mailers/previews/digest_mailer_preview.rb | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/helpers/mail_digest_helper.rb b/app/helpers/mail_digest_helper.rb index a449114a15a1..7baebba824a9 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 @@ def timestamp_text(user, journal) 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 10c1b341fa9b..44aa78f1d000 100644 --- a/spec/mailers/digest_mailer_spec.rb +++ b/spec/mailers/digest_mailer_spec.rb @@ -102,7 +102,7 @@ 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 e43ee6ff0b3d..816240ae23d6 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