Update "newsletter" notification email to add unsubscribe link

This commit is contained in:
taitus
2021-02-01 18:21:16 +01:00
committed by Javi Martín
parent 1fcbd49448
commit 13965901f8
5 changed files with 16 additions and 2 deletions

View File

@@ -120,6 +120,7 @@ class Mailer < ApplicationMailer
def newsletter(newsletter, recipient_email)
@newsletter = newsletter
@email_to = recipient_email
manage_subscriptions_token(User.find_by(email: @email_to))
mail(to: @email_to, from: @newsletter.from, subject: @newsletter.subject)
end

View File

@@ -2,4 +2,15 @@
<p style="font-family: 'Open Sans','Helvetica Neue',arial,sans-serif;font-size: 14px;line-height: 24px;">
<%= auto_link_already_sanitized_html wysiwyg(@newsletter.body) %>
</p>
<p style="font-family: 'Open Sans','Helvetica Neue',arial,sans-serif;font-size: 12px;font-weight: normal;line-height: 20px;">
<%= sanitize(t("mailers.config.unsubscribe_text",
notifications: link_to(
t("mailers.config.notifications_link"),
edit_subscriptions_url(token: @token),
style: "color: #2895F1; text-decoration: none;"
),
notification: User.human_attribute_name(:newsletter)
)) %>
</p>
</td>

View File

@@ -8,7 +8,6 @@ en:
subject: Someone has commented on your %{commentable}
title: New comment
config:
manage_email_subscriptions: To stop receiving these emails change your settings in
notifications_link: Notifications
unsubscribe_text: 'To unsubscribe from these emails, visit %{notifications} and uncheck "%{notification}".'
email_verification:

View File

@@ -8,7 +8,6 @@ es:
subject: Alguien ha comentado en tu %{commentable}
title: Nuevo comentario
config:
manage_email_subscriptions: Puedes dejar de recibir estos emails cambiando tu configuración en
notifications_link: Notificaciones
unsubscribe_text: 'Para darse de baja de estos emails, puedes entrar en %{notifications} y desmarcar la opción "%{notification}".'
email_verification:

View File

@@ -502,6 +502,10 @@ describe "Emails" do
expect(email).to have_subject("This is a different subject")
expect(email).to deliver_from("no-reply@consul.dev")
expect(email.body.encoded).to include("This is a different body")
expect(email).to have_body_text("To unsubscribe from these emails, visit")
expect(email).to have_body_text(
edit_subscriptions_path(token: user_with_newsletter_in_segment_2.subscriptions_token))
expect(email).to have_body_text('and uncheck "Receive by email website relevant information"')
end
end