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
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Allow provided salutation in announcement
Oliver Günthered8a0df4f7b4
diff --git a/app/mailers/announcement_mailer.rb b/app/mailers/announcement_mailer.rbindex 9a51655d90b..ca6cf11995b 100644--- a/app/mailers/announcement_mailer.rb+++ b/app/mailers/announcement_mailer.rb@@ -35,7 +35,7 @@ class AnnouncementMailer < ApplicationMailerinclude OpenProject::TextFormattinghelper :mail_notification- def announce(user, subject:, body:, body_header: nil, body_subheader: nil)+ def announce(user, subject:, body:, salutation: :firstname, body_header: nil, body_subheader: nil)with_locale_for(user) dolocalized_subject = localized(subject)@@ -44,6 +44,7 @@ class AnnouncementMailer < ApplicationMailerlocals = {body: localized(body),user:,+ salutation: user_salutation(user, salutation),header_summary: localized_subject,body_header: localized(body_header),body_subheader: localized(body_subheader)@@ -64,4 +65,13 @@ class AnnouncementMailer < ApplicationMailerinputendend++ def user_salutation(user, salutation)+ case salutation+ when :firstname+ I18n.t(:'mail.salutation', user: user.firstname)+ else+ salutation % { firstname: user.firstname, lastname: user.lastname, name: user.name }+ end+ endenddiff --git a/app/views/announcement_mailer/announce.html.erb b/app/views/announcement_mailer/announce.html.erbindex d969fee8226..6f5d9c32d03 100644--- a/app/views/announcement_mailer/announce.html.erb+++ b/app/views/announcement_mailer/announce.html.erb@@ -2,6 +2,7 @@<%= render partial: 'mailer/notification_mailer_header',locals: {summary: header_summary,+ salutation: salutation,user: user} %>diff --git a/app/views/announcement_mailer/announce.text.erb b/app/views/announcement_mailer/announce.text.erbindex 2dc124efdf9..ae763a29f2f 100644--- a/app/views/announcement_mailer/announce.text.erb+++ b/app/views/announcement_mailer/announce.text.erb@@ -1,4 +1,4 @@-<%= I18n.t(:'mail.salutation', user: user.firstname) %>+<%= salutation %><%= header_summary %><%= "-" * 100 %>diff --git a/app/views/digest_mailer/work_packages.html.erb b/app/views/digest_mailer/work_packages.html.erbindex 462130cbdf3..c20d8d4b22f 100644--- a/app/views/digest_mailer/work_packages.html.erb+++ b/app/views/digest_mailer/work_packages.html.erb@@ -13,7 +13,8 @@summary: "#{I18n.t(:'mail.digests.you_have')} #{digest_summary_text(@notification_ids.length, @mentioned_count)}",button_href: notifications_center_url,button_text: I18n.t(:'mail.notification.center'),- user: @user+ user: @user,+ salutation: I18n.t(:'mail.salutation', user: @user.firstname)} %><% @aggregated_notifications.first(DigestMailer::MAX_SHOWN_WORK_PACKAGES).each do | work_package, notifications_by_work_package| %>diff --git a/app/views/mailer/_notification_mailer_header.html.erb b/app/views/mailer/_notification_mailer_header.html.erbindex cbfeb7ac733..6e879367124 100644--- a/app/views/mailer/_notification_mailer_header.html.erb+++ b/app/views/mailer/_notification_mailer_header.html.erb@@ -8,7 +8,7 @@<tr><td><span style="font-size: 24px; color: #333333;">- <%= I18n.t(:'mail.salutation', user: user.firstname) %>+ <%= salutation %></span></td></tr>diff --git a/app/views/work_package_mailer/mentioned.html.erb b/app/views/work_package_mailer/mentioned.html.erbindex 5d34c04cadd..986b6596dc1 100644--- a/app/views/work_package_mailer/mentioned.html.erb+++ b/app/views/work_package_mailer/mentioned.html.erb@@ -13,7 +13,8 @@summary: I18n.t(:'mail.work_packages.mentioned_by', user: @journal.user),button_href: notifications_path(@work_package.id),button_text: I18n.t(:'mail.notification.see_in_center'),- user: @user+ user: @user,+ salutation: I18n.t(:'mail.salutation', user: @user.firstname)} %><%= render layout: 'mailer/notification_row',diff --git a/spec/mailers/announcement_mailer_spec.rb b/spec/mailers/announcement_mailer_spec.rbindex d2bcba81894..5afa3a9dedc 100644--- a/spec/mailers/announcement_mailer_spec.rb+++ b/spec/mailers/announcement_mailer_spec.rb@@ -59,5 +59,22 @@ describe AnnouncementMailer, type: :mailer doexpect(mail.to).to match_array [recipient.mail]end++ context 'with custom salutation' do+ subject(:mail) do+ described_class.announce(recipient,+ subject: announcement_subject,+ salutation: "What's up %<name>s?",+ body: announcement_body)+ end++ it 'includes the body' do+ expect(mail.body.encoded)+ .to include("What's up #{recipient.name}")++ expect(mail.body.encoded)+ .not_to include("Hey #{recipient.name}!")+ end+ endendend