From c529a33cc7032cbf0f5913bc5a0ad393e990b075 Mon Sep 17 00:00:00 2001 From: Diego Basterrech <40240968+diebas@users.noreply.github.com> Date: Wed, 16 Oct 2024 16:34:55 -0300 Subject: [PATCH] Update Bulk Email greeting (#4662) --- .../app/models/bulk_email/delivery_form.rb | 6 +++--- .../app/services/bulk_email/content_generator.rb | 10 ++++------ vendor/engines/bulk_email/config/locales/en.yml | 2 +- .../services/bulk_email/content_generator_spec.rb | 13 ++----------- 4 files changed, 10 insertions(+), 21 deletions(-) diff --git a/vendor/engines/bulk_email/app/models/bulk_email/delivery_form.rb b/vendor/engines/bulk_email/app/models/bulk_email/delivery_form.rb index 838233e311..b6a62dbe1a 100644 --- a/vendor/engines/bulk_email/app/models/bulk_email/delivery_form.rb +++ b/vendor/engines/bulk_email/app/models/bulk_email/delivery_form.rb @@ -46,8 +46,8 @@ def subject "#{content_generator.subject_prefix} #{custom_subject}" end - def body(recipient_name = nil) - content_generator.wrap_text(custom_message, recipient_name) + def body + content_generator.wrap_text(custom_message) end def reply_to @@ -56,7 +56,7 @@ def reply_to def deliver(recipient) Mailer - .send_mail(recipient: recipient, subject: subject, body: body(recipient.full_name), reply_to: reply_to, facility: SerializableFacility.new(facility)) + .send_mail(recipient: recipient, subject: subject, body: body, reply_to: reply_to, facility: SerializableFacility.new(facility)) .deliver_later end diff --git a/vendor/engines/bulk_email/app/services/bulk_email/content_generator.rb b/vendor/engines/bulk_email/app/services/bulk_email/content_generator.rb index 180bc0eebc..55f5efdb4a 100644 --- a/vendor/engines/bulk_email/app/services/bulk_email/content_generator.rb +++ b/vendor/engines/bulk_email/app/services/bulk_email/content_generator.rb @@ -6,8 +6,6 @@ class ContentGenerator include TextHelpers::Translation - DEFAULT_RECIPIENT_NAME = "Firstname Lastname" - attr_reader :facility, :subject_product def initialize(facility, subject_product = nil) @@ -23,13 +21,13 @@ def subject_prefix end end - def wrap_text(text, recipient_name = nil) - [greeting(recipient_name), text].compact.join("\n\n") + def wrap_text(text) + [greeting, text].compact.join("\n\n") end - def greeting(recipient_name = nil) + def greeting [ - text("body.greeting", recipient_name: recipient_name || DEFAULT_RECIPIENT_NAME), + text("body.greeting"), reason_statement, ].compact.join("\n\n") end diff --git a/vendor/engines/bulk_email/config/locales/en.yml b/vendor/engines/bulk_email/config/locales/en.yml index 99c78328cc..7f43baab84 100644 --- a/vendor/engines/bulk_email/config/locales/en.yml +++ b/vendor/engines/bulk_email/config/locales/en.yml @@ -30,7 +30,7 @@ en: subject_prefix: "[!app_name!]" subject_prefix_with_facility: "[!app_name! %{abbreviation}]" body: - greeting: Hello %{recipient_name}, + greeting: Hello, delivery: success: one: "%{count} email message queued successfully." diff --git a/vendor/engines/bulk_email/spec/services/bulk_email/content_generator_spec.rb b/vendor/engines/bulk_email/spec/services/bulk_email/content_generator_spec.rb index 1f78a5acde..8f7a8b0696 100644 --- a/vendor/engines/bulk_email/spec/services/bulk_email/content_generator_spec.rb +++ b/vendor/engines/bulk_email/spec/services/bulk_email/content_generator_spec.rb @@ -10,17 +10,8 @@ let(:recipient) { FactoryBot.build(:user) } describe "#greeting" do - context "without a recipient name" do - it "generates a greeting with a placeholder name" do - expect(subject.greeting).to include("Firstname Lastname") - end - end - - context "with a recipient name" do - it "generates a greeting with a placeholder name" do - expect(subject.greeting(recipient.full_name)) - .to include(recipient.full_name) - end + it "generates a greeting" do + expect(subject.greeting).to include(I18n.t('bulk_email.body.greeting')) end context "with an offline instrument as a subject_product" do