Update "comment" 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. We also adapted the existing generic text by adding a description of the related notification.
This commit is contained in:
@@ -9,6 +9,7 @@ class Mailer < ApplicationMailer
|
||||
@comment = comment
|
||||
@commentable = comment.commentable
|
||||
@email_to = @commentable.author.email
|
||||
manage_subscriptions_token(@commentable.author)
|
||||
|
||||
with_user(@commentable.author) do
|
||||
subject = t("mailers.comment.subject", commentable: t("activerecord.models.#{@commentable.class.name.underscore}", count: 1).downcase)
|
||||
@@ -150,4 +151,9 @@ class Mailer < ApplicationMailer
|
||||
mail.perform_deliveries = false
|
||||
end
|
||||
end
|
||||
|
||||
def manage_subscriptions_token(user)
|
||||
user.add_subscriptions_token
|
||||
@token = user.subscriptions_token
|
||||
end
|
||||
end
|
||||
|
||||
@@ -18,6 +18,13 @@
|
||||
</p>
|
||||
|
||||
<p style="font-family: 'Open Sans','Helvetica Neue',arial,sans-serif;font-size: 12px;font-weight: normal;line-height: 20px;">
|
||||
<%= t("mailers.config.manage_email_subscriptions") %> <%= link_to t("account.show.title"), account_url, style: "color: #2895F1; text-decoration:none;" %>
|
||||
<%= 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(:email_on_comment)
|
||||
)) %>
|
||||
</p>
|
||||
</td>
|
||||
|
||||
@@ -9,6 +9,8 @@ en:
|
||||
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:
|
||||
click_here_to_verify: this link
|
||||
instructions_2: This email will verify your account with <b>%{document_type} %{document_number}</b>. If these don't belong to you, please don't click on the previous link and ignore this email.
|
||||
|
||||
@@ -9,6 +9,8 @@ es:
|
||||
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:
|
||||
click_here_to_verify: en este enlace
|
||||
instructions_2: Este email es para verificar tu cuenta con <b>%{document_type} %{document_number}</b>. Si esos no son tus datos, por favor no pulses el enlace anterior e ignora este email.
|
||||
|
||||
@@ -29,4 +29,26 @@ describe Mailer do
|
||||
expect(email.subject).to include("commented on your proposal")
|
||||
end
|
||||
end
|
||||
|
||||
describe "#manage_subscriptions_token" do
|
||||
let(:user) { create(:user) }
|
||||
let(:proposal) { create(:proposal, author: user) }
|
||||
let(:comment) { create(:comment, commentable: proposal) }
|
||||
|
||||
it "generates a subscriptions token when the receiver doesn't have one" do
|
||||
user.update!(subscriptions_token: nil)
|
||||
|
||||
Mailer.comment(comment).deliver_now
|
||||
|
||||
expect(user.reload.subscriptions_token).to be_present
|
||||
end
|
||||
|
||||
it "uses the existing subscriptions token when the receivesr already has one" do
|
||||
user.update!(subscriptions_token: "subscriptions_token_value")
|
||||
|
||||
Mailer.comment(comment).deliver_now
|
||||
|
||||
expect(user.subscriptions_token).to eq "subscriptions_token_value"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -155,6 +155,9 @@ describe "System Emails" do
|
||||
expect(page).to have_content comment.body
|
||||
|
||||
expect(page).to have_link "Let's do...", href: debate_url(debate, host: app_host)
|
||||
expect(page).to have_link("Notifications",
|
||||
href: edit_subscriptions_url(token: user.subscriptions_token,
|
||||
host: app_host))
|
||||
end
|
||||
|
||||
scenario "#reply" do
|
||||
|
||||
@@ -50,8 +50,10 @@ describe "Emails" do
|
||||
expect(email).to have_subject("Someone has commented on your citizen proposal")
|
||||
expect(email).to deliver_to(proposal.author)
|
||||
expect(email).to have_body_text(proposal_path(proposal))
|
||||
expect(email).to have_body_text("To stop receiving these emails change your settings in")
|
||||
expect(email).to have_body_text(account_path)
|
||||
expect(email).to have_body_text("To unsubscribe from these emails, visit")
|
||||
expect(email).to have_body_text(edit_subscriptions_path(token: proposal.author.subscriptions_token))
|
||||
expect(email).to have_body_text(
|
||||
'and uncheck "Notify me by email when someone comments on my proposals or debates"')
|
||||
end
|
||||
|
||||
scenario "Do not send email about own proposal comments" do
|
||||
@@ -77,8 +79,10 @@ describe "Emails" do
|
||||
expect(email).to have_subject("Someone has commented on your debate")
|
||||
expect(email).to deliver_to(debate.author)
|
||||
expect(email).to have_body_text(debate_path(debate))
|
||||
expect(email).to have_body_text("To stop receiving these emails change your settings in")
|
||||
expect(email).to have_body_text(account_path)
|
||||
expect(email).to have_body_text("To unsubscribe from these emails, visit")
|
||||
expect(email).to have_body_text(edit_subscriptions_path(token: debate.author.subscriptions_token))
|
||||
expect(email).to have_body_text(
|
||||
'and uncheck "Notify me by email when someone comments on my proposals or debates"')
|
||||
end
|
||||
|
||||
scenario "Do not send email about own debate comments" do
|
||||
@@ -104,8 +108,10 @@ describe "Emails" do
|
||||
expect(email).to have_subject("Someone has commented on your investment")
|
||||
expect(email).to deliver_to(investment.author)
|
||||
expect(email).to have_body_text(budget_investment_path(investment, budget_id: investment.budget_id))
|
||||
expect(email).to have_body_text("To stop receiving these emails change your settings in")
|
||||
expect(email).to have_body_text(account_path)
|
||||
expect(email).to have_body_text("To unsubscribe from these emails, visit")
|
||||
expect(email).to have_body_text(edit_subscriptions_path(token: investment.author.subscriptions_token))
|
||||
expect(email).to have_body_text(
|
||||
'and uncheck "Notify me by email when someone comments on my proposals or debates"')
|
||||
end
|
||||
|
||||
scenario "Do not send email about own budget investments comments" do
|
||||
@@ -132,8 +138,10 @@ describe "Emails" do
|
||||
expect(email).to have_subject("Someone has commented on your topic")
|
||||
expect(email).to deliver_to(topic.author)
|
||||
expect(email).to have_body_text(community_topic_path(topic, community_id: topic.community_id))
|
||||
expect(email).to have_body_text("To stop receiving these emails change your settings in")
|
||||
expect(email).to have_body_text(account_path)
|
||||
expect(email).to have_body_text("To unsubscribe from these emails, visit")
|
||||
expect(email).to have_body_text(edit_subscriptions_path(token: topic.author.subscriptions_token))
|
||||
expect(email).to have_body_text(
|
||||
'and uncheck "Notify me by email when someone comments on my proposals or debates"')
|
||||
end
|
||||
|
||||
scenario "Do not send email about own topic comments" do
|
||||
@@ -159,8 +167,10 @@ describe "Emails" do
|
||||
expect(email).to have_subject("Someone has commented on your poll")
|
||||
expect(email).to deliver_to(poll.author)
|
||||
expect(email).to have_body_text(poll_path(poll))
|
||||
expect(email).to have_body_text("To stop receiving these emails change your settings in")
|
||||
expect(email).to have_body_text(account_path)
|
||||
expect(email).to have_body_text("To unsubscribe from these emails, visit")
|
||||
expect(email).to have_body_text(edit_subscriptions_path(token: poll.author.subscriptions_token))
|
||||
expect(email).to have_body_text(
|
||||
'and uncheck "Notify me by email when someone comments on my proposals or debates"')
|
||||
end
|
||||
|
||||
scenario "Do not send email about own poll comments" do
|
||||
|
||||
Reference in New Issue
Block a user