From 478ac3a952d8df2b454330654e2f4b9bbf216a32 Mon Sep 17 00:00:00 2001 From: taitus Date: Tue, 29 Dec 2020 12:25:29 +0100 Subject: [PATCH] Update "proposal" notification email to add unsubscribe link We modified the link that previously redirected us to the "My content" page to redirect us to the new page for managing subscriptions. --- app/mailers/mailer.rb | 1 + app/views/mailer/proposal_notification_digest.html.erb | 7 ++++--- config/locales/en/mailers.yml | 3 +-- config/locales/es/mailers.yml | 3 +-- spec/system/admin/system_emails_spec.rb | 1 + spec/system/emails_spec.rb | 2 +- 6 files changed, 9 insertions(+), 8 deletions(-) diff --git a/app/mailers/mailer.rb b/app/mailers/mailer.rb index 73e8fa903..a32cd82dd 100644 --- a/app/mailers/mailer.rb +++ b/app/mailers/mailer.rb @@ -62,6 +62,7 @@ class Mailer < ApplicationMailer def proposal_notification_digest(user, notifications) @notifications = notifications @email_to = user.email + manage_subscriptions_token(user) with_user(user) do mail(to: @email_to, subject: t("mailers.proposal_notification_digest.title", org_name: Setting["org_name"])) diff --git a/app/views/mailer/proposal_notification_digest.html.erb b/app/views/mailer/proposal_notification_digest.html.erb index 576b592cd..7b3d0f58b 100644 --- a/app/views/mailer/proposal_notification_digest.html.erb +++ b/app/views/mailer/proposal_notification_digest.html.erb @@ -70,9 +70,10 @@

- <%= sanitize(t("mailers.proposal_notification_digest.unsubscribe", - account: link_to(t("mailers.proposal_notification_digest.unsubscribe_account"), - account_url, style: "color: #2895F1; text-decoration: none;"))) %> + <%= sanitize(t("mailers.proposal_notification_digest.unsubscribe_text", + notifications: link_to(t("mailers.config.notifications_link"), + edit_subscriptions_url(token: @token), + style: "color: #2895F1; text-decoration: none;"))) %>

diff --git a/config/locales/en/mailers.yml b/config/locales/en/mailers.yml index 1960ca558..36482beaa 100644 --- a/config/locales/en/mailers.yml +++ b/config/locales/en/mailers.yml @@ -28,8 +28,7 @@ en: title: "Proposal notifications in %{org_name}" share: Share proposal comment: Comment proposal - unsubscribe: "If you don't want to receive any proposal notifications, visit %{account} and uncheck 'Receive a summary of proposal notifications'." - unsubscribe_account: My account + unsubscribe_text: "If you don't want to receive any proposal notifications, visit %{notifications} and uncheck 'Receive a summary of proposal notifications'." unfollow: "Visit this proposal and unfollow it to stop receiving notifications." direct_message_for_receiver: subject: "You have received a new private message" diff --git a/config/locales/es/mailers.yml b/config/locales/es/mailers.yml index 961c88b96..fa08d810a 100644 --- a/config/locales/es/mailers.yml +++ b/config/locales/es/mailers.yml @@ -28,8 +28,7 @@ es: title: "Notificaciones de propuestas en %{org_name}" share: Compartir propuesta comment: Comentar propuesta - unsubscribe: "Si no quieres recibir notificaciones de propuestas, puedes entrar en %{account} y desmarcar la opción 'Recibir resumen de notificaciones sobre propuestas'." - unsubscribe_account: Mi cuenta + unsubscribe_text: "Si no quieres recibir notificaciones de propuestas, puedes entrar en %{notifications} y desmarcar la opción 'Recibir resumen de notificaciones sobre propuestas'." unfollow: "Si no quieres recibir más notificaciones, visita esta propuesta y deja de seguirla." direct_message_for_receiver: subject: "Has recibido un nuevo mensaje privado" diff --git a/spec/system/admin/system_emails_spec.rb b/spec/system/admin/system_emails_spec.rb index 1d8d8fca9..cfcd3cf70 100644 --- a/spec/system/admin/system_emails_spec.rb +++ b/spec/system/admin/system_emails_spec.rb @@ -92,6 +92,7 @@ describe "System Emails" do href: proposal_url(proposal_b, anchor: "tab-notifications", host: app_host)) expect(page).to have_content("Proposal A Notification Body") expect(page).to have_content("Proposal B Notification Body") + expect(page).to have_link "Notifications" end scenario "#budget_investment_created" do diff --git a/spec/system/emails_spec.rb b/spec/system/emails_spec.rb index a77863432..46e859104 100644 --- a/spec/system/emails_spec.rb +++ b/spec/system/emails_spec.rb @@ -303,7 +303,7 @@ describe "Emails" do expect(email).to have_body_text(proposal2.author.name) expect(email).not_to have_body_text(proposal3.title) - expect(email).to have_body_text(/#{account_path}/) + expect(email).to have_body_text(edit_subscriptions_path(token: user.subscriptions_token)) expect(email).to have_body_text("Visit this proposal and unfollow it to stop receiving notifications.") notification1.reload