Skip to content

Commit

Permalink
Merge pull request #461 from alphagov/explain-why-youre-getting-emails
Browse files Browse the repository at this point in the history
Update unsubscribe link to explain up-front why you're receiving emails
  • Loading branch information
pixeltrix committed May 5, 2016
2 parents 5e0e785 + 344e8cf commit 6174356
Show file tree
Hide file tree
Showing 18 changed files with 124 additions and 19 deletions.
8 changes: 7 additions & 1 deletion app/views/petition_mailer/email_creator.html.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
<p><small>You’re receiving this email because you created this petition.</small></p>
<p><small>To unsubscribe: <%= link_to nil, unsubscribe_signature_url(@signature, @signature.unsubscribe_token) %></small></p>
<hr>

<p>Dear <%= @signature.name %>,</p>

<p>You recently created the petition "<%= @petition.action %>":<br />
Expand All @@ -9,4 +13,6 @@
<%= t("petitions.emails.signoff_prefix") %><br />
<%= t("petitions.emails.signoff_suffix") %></p>

<p><small>You’re receiving this email because you created this petition. <%= link_to 'Unsubscribe', unsubscribe_signature_url(@signature, @signature.unsubscribe_token) %></small></p>
<hr>
<p><small>You’re receiving this email because you created this petition.</small></p>
<p><small>To unsubscribe: <%= link_to nil, unsubscribe_signature_url(@signature, @signature.unsubscribe_token) %></small></p>
8 changes: 7 additions & 1 deletion app/views/petition_mailer/email_creator.text.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
You’re receiving this email because you created this petition.
To unsubscribe: <%= unsubscribe_signature_url(@signature, @signature.unsubscribe_token) %>
--

Dear <%= @signature.name %>,

You recently created the petition "<%= @petition.action %>":
Expand All @@ -9,4 +13,6 @@ Thanks,
<%= t("petitions.emails.signoff_prefix") %>
<%= t("petitions.emails.signoff_suffix") %>

You’re receiving this email because you created this petition. Unsubscribe: <%= unsubscribe_signature_url(@signature, @signature.unsubscribe_token) %>
--
You’re receiving this email because you created this petition.
To unsubscribe: <%= unsubscribe_signature_url(@signature, @signature.unsubscribe_token) %>
8 changes: 7 additions & 1 deletion app/views/petition_mailer/email_signer.html.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
<p><small>You’re receiving this email because you signed this petition.</small></p>
<p><small>To unsubscribe: <%= link_to nil, unsubscribe_signature_url(@signature, @signature.unsubscribe_token) %></small></p>
<hr>

<p>Dear <%= @signature.name %>,</p>

<p>You recently signed the petition "<%= @petition.action %>":<br />
Expand All @@ -9,4 +13,6 @@
<%= t("petitions.emails.signoff_prefix") %><br />
<%= t("petitions.emails.signoff_suffix") %></p>

<p><small>You’re receiving this email because you signed this petition. <%= link_to 'Unsubscribe', unsubscribe_signature_url(@signature, @signature.unsubscribe_token) %></small></p>
<hr>
<p><small>You’re receiving this email because you signed this petition.</small></p>
<p><small>To unsubscribe: <%= link_to nil, unsubscribe_signature_url(@signature, @signature.unsubscribe_token) %></small></p>
8 changes: 7 additions & 1 deletion app/views/petition_mailer/email_signer.text.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
You’re receiving this email because you signed this petition.
To unsubscribe: <%= unsubscribe_signature_url(@signature, @signature.unsubscribe_token) %>
--

Dear <%= @signature.name %>,

You recently signed the petition "<%= @petition.action %>":
Expand All @@ -9,4 +13,6 @@ Thanks,
<%= t("petitions.emails.signoff_prefix") %>
<%= t("petitions.emails.signoff_suffix") %>

You’re receiving this email because you signed this petition. Unsubscribe: <%= unsubscribe_signature_url(@signature, @signature.unsubscribe_token) %>
--
You’re receiving this email because you signed this petition.
To unsubscribe: <%= unsubscribe_signature_url(@signature, @signature.unsubscribe_token) %>
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
<p><small>You’re receiving this email because you created this petition.</small></p>
<p><small>To unsubscribe: <%= link_to nil, unsubscribe_signature_url(@signature, @signature.unsubscribe_token) %></small></p>
<hr>

<p>Dear <%= @signature.name %>,</p>

<% if @debate_outcome.debated? %>
Expand Down Expand Up @@ -32,4 +36,6 @@
<%= t("petitions.emails.signoff_prefix") %><br />
<%= t("petitions.emails.signoff_suffix") %></p>

<p><small>You’re receiving this email because you created this petition. <%= link_to 'Unsubscribe', unsubscribe_signature_url(@signature, @signature.unsubscribe_token) %></small></p>
<hr>
<p><small>You’re receiving this email because you created this petition.</small></p>
<p><small>To unsubscribe: <%= link_to nil, unsubscribe_signature_url(@signature, @signature.unsubscribe_token) %></small></p>
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
You’re receiving this email because you created this petition.
To unsubscribe: <%= unsubscribe_signature_url(@signature, @signature.unsubscribe_token) %>
--

Dear <%= @signature.name %>,

<% if @debate_outcome.debated? %>
Expand Down Expand Up @@ -33,4 +37,6 @@ Thanks,
<%= t("petitions.emails.signoff_prefix") %>
<%= t("petitions.emails.signoff_suffix") %>

You’re receiving this email because you created this petition. Unsubscribe: <%= unsubscribe_signature_url(@signature, @signature.unsubscribe_token) %>
--
You’re receiving this email because you created this petition.
To unsubscribe: <%= unsubscribe_signature_url(@signature, @signature.unsubscribe_token) %>
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
<p><small>You’re receiving this email because you created this petition.</small></p>
<p><small>To unsubscribe: <%= link_to nil, unsubscribe_signature_url(@signature, @signature.unsubscribe_token) %></small></p>
<hr>

<p>Dear <%= @signature.name %>,</p>

<p>Parliament is going to debate your petition – “<%= @petition.action %>”.</p>
Expand All @@ -12,4 +16,6 @@
<%= t("petitions.emails.signoff_prefix") %><br />
<%= t("petitions.emails.signoff_suffix") %></p>

<p><small>You’re receiving this email because you created this petition. <%= link_to 'Unsubscribe', unsubscribe_signature_url(@signature, @signature.unsubscribe_token) %></small></p>
<hr>
<p><small>You’re receiving this email because you created this petition.</small></p>
<p><small>To unsubscribe: <%= link_to nil, unsubscribe_signature_url(@signature, @signature.unsubscribe_token) %></small></p>
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
You’re receiving this email because you created this petition.
To unsubscribe: <%= unsubscribe_signature_url(@signature, @signature.unsubscribe_token) %>
--

Dear <%= @signature.name %>,

Parliament is going to debate your petition – "<%= @petition.action %>".
Expand All @@ -12,4 +16,6 @@ Thanks,
<%= t("petitions.emails.signoff_prefix") %>
<%= t("petitions.emails.signoff_suffix") %>

You’re receiving this email because you created this petition. Unsubscribe: <%= unsubscribe_signature_url(@signature, @signature.unsubscribe_token) %>
--
You’re receiving this email because you created this petition.
To unsubscribe: <%= unsubscribe_signature_url(@signature, @signature.unsubscribe_token) %>
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
<p><small>You’re receiving this email because you created this petition.</small></p>
<p><small>To unsubscribe: <%= link_to nil, unsubscribe_signature_url(@signature, @signature.unsubscribe_token) %></small></p>
<hr>

<p>Dear <%= @signature.name %>,</p>

<p>The Government has responded to your petition – “<%= link_to @petition.action, petition_url(@petition) %>”.</p>
Expand All @@ -24,4 +28,6 @@
<%= t("petitions.emails.signoff_prefix") %><br />
<%= t("petitions.emails.signoff_suffix") %></p>

<p><small>You’re receiving this email because you created this petition. <%= link_to 'Unsubscribe', unsubscribe_signature_url(@signature, @signature.unsubscribe_token) %></small></p>
<hr>
<p><small>You’re receiving this email because you created this petition.</small></p>
<p><small>To unsubscribe: <%= link_to nil, unsubscribe_signature_url(@signature, @signature.unsubscribe_token) %></small></p>
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
You’re receiving this email because you created this petition.
To unsubscribe: <%= unsubscribe_signature_url(@signature, @signature.unsubscribe_token) %>
--

Dear <%= @signature.name %>,

The Government has responded to your petition – "<%= @petition.action %>".
Expand All @@ -24,4 +28,6 @@ Thanks,
<%= t("petitions.emails.signoff_prefix") %>
<%= t("petitions.emails.signoff_suffix") %>

You’re receiving this email because you created this petition. Unsubscribe: <%= unsubscribe_signature_url(@signature, @signature.unsubscribe_token) %>
--
You’re receiving this email because you created this petition.
To unsubscribe: <%= unsubscribe_signature_url(@signature, @signature.unsubscribe_token) %>
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
<p><small>You’re receiving this email because you signed this petition.</small></p>
<p><small>To unsubscribe: <%= link_to nil, unsubscribe_signature_url(@signature, @signature.unsubscribe_token) %></small></p>
<hr>

<p>Dear <%= @signature.name %>,</p>

<% if @debate_outcome.debated? %>
Expand Down Expand Up @@ -32,4 +36,6 @@
<%= t("petitions.emails.signoff_prefix") %><br />
<%= t("petitions.emails.signoff_suffix") %></p>

<p><small>You’re receiving this email because you signed this petition. <%= link_to 'Unsubscribe', unsubscribe_signature_url(@signature, @signature.unsubscribe_token) %></small></p>
<hr>
<p><small>You’re receiving this email because you signed this petition.</small></p>
<p><small>To unsubscribe: <%= link_to nil, unsubscribe_signature_url(@signature, @signature.unsubscribe_token) %></small></p>
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
You’re receiving this email because you signed this petition.
To unsubscribe: <%= unsubscribe_signature_url(@signature, @signature.unsubscribe_token) %>
--

Dear <%= @signature.name %>,

<% if @debate_outcome.debated? %>
Expand Down Expand Up @@ -33,4 +37,6 @@ Thanks,
<%= t("petitions.emails.signoff_prefix") %>
<%= t("petitions.emails.signoff_suffix") %>

You’re receiving this email because you signed this petition. Unsubscribe: <%= unsubscribe_signature_url(@signature, @signature.unsubscribe_token) %>
--
You’re receiving this email because you signed this petition.
To unsubscribe: <%= unsubscribe_signature_url(@signature, @signature.unsubscribe_token) %>
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
<p><small>You’re receiving this email because you signed this petition.</small></p>
<p><small>To unsubscribe: <%= link_to nil, unsubscribe_signature_url(@signature, @signature.unsubscribe_token) %></small></p>
<hr>

<p>Dear <%= @signature.name %>,</p>

<p>Parliament is going to debate the petition you signed – “<%= @petition.action %>”.</p>
Expand All @@ -12,4 +16,6 @@
<%= t("petitions.emails.signoff_prefix") %><br />
<%= t("petitions.emails.signoff_suffix") %></p>

<p><small>You’re receiving this email because you signed this petition. <%= link_to 'Unsubscribe', unsubscribe_signature_url(@signature, @signature.unsubscribe_token) %></small></p>
<hr>
<p><small>You’re receiving this email because you signed this petition.</small></p>
<p><small>To unsubscribe: <%= link_to nil, unsubscribe_signature_url(@signature, @signature.unsubscribe_token) %></small></p>
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
You’re receiving this email because you signed this petition.
To unsubscribe: <%= unsubscribe_signature_url(@signature, @signature.unsubscribe_token) %>
--

Dear <%= @signature.name %>,

Parliament is going to debate the petition you signed – "<%= @petition.action %>".
Expand All @@ -12,4 +16,6 @@ Thanks,
<%= t("petitions.emails.signoff_prefix") %>
<%= t("petitions.emails.signoff_suffix") %>

You’re receiving this email because you signed this petition. Unsubscribe: <%= unsubscribe_signature_url(@signature, @signature.unsubscribe_token) %>
--
You’re receiving this email because you signed this petition.
To unsubscribe: <%= unsubscribe_signature_url(@signature, @signature.unsubscribe_token) %>
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
<p><small>You’re receiving this email because you signed this petition.</small></p>
<p><small>To unsubscribe: <%= link_to nil, unsubscribe_signature_url(@signature, @signature.unsubscribe_token) %></small></p>
<hr>

<p>Dear <%= @signature.name %>,</p>

<p>The Government has responded to the petition you signed – “<%= link_to @petition.action, petition_url(@petition) %>”.</p>
Expand All @@ -24,4 +28,6 @@
<%= t("petitions.emails.signoff_prefix") %><br />
<%= t("petitions.emails.signoff_suffix") %></p>

<p><small>You’re receiving this email because you signed this petition. <%= link_to 'Unsubscribe', unsubscribe_signature_url(@signature, @signature.unsubscribe_token) %></small></p>
<hr>
<p><small>You’re receiving this email because you signed this petition.</small></p>
<p><small>To unsubscribe: <%= link_to nil, unsubscribe_signature_url(@signature, @signature.unsubscribe_token) %></small></p>
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
You’re receiving this email because you signed this petition.
To unsubscribe: <%= unsubscribe_signature_url(@signature, @signature.unsubscribe_token) %>
--

Dear <%= @signature.name %>,

The Government has responded to the petition you signed – "<%= @petition.action %>".
Expand All @@ -24,4 +28,6 @@ Thanks,
<%= t("petitions.emails.signoff_prefix") %>
<%= t("petitions.emails.signoff_suffix") %>

You’re receiving this email because you signed this petition. Unsubscribe: <%= unsubscribe_signature_url(@signature, @signature.unsubscribe_token) %>
--
You’re receiving this email because you signed this petition.
To unsubscribe: <%= unsubscribe_signature_url(@signature, @signature.unsubscribe_token) %>
4 changes: 2 additions & 2 deletions features/step_definitions/debate_scheduled_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Then "#{@petition.creator_signature.email}" should receive an email
When they open the email
Then they should see "Parliament is going to debate your petition" in the email body
When they click the first link in the email
When they click the second link in the email
Then I should be on the petition page for "#{@petition.action}"
)
end
Expand All @@ -16,7 +16,7 @@
Then "#{signatory.email}" should receive an email
When they open the email
Then they should see "Parliament is going to debate the petition" in the email body
When they click the first link in the email
When they click the second link in the email
Then I should be on the petition page for "#{@petition.action}"
)
end
Expand Down
11 changes: 10 additions & 1 deletion features/step_definitions/email_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,12 @@ def current_email_address
end

def text_and_links_in_email(email)
email.default_part_body.to_s.scan(%r{<a[^>]+href="([^"]+)"[^>]*>([^<]+)</a>})
html = Nokogiri::HTML(email.default_part_body.to_s)
html.xpath("//a").map{ |node| [node["href"], node.text] }
end

def links_in_email(email)
text_and_links_in_email(email).map(&:first)
end
end

Expand Down Expand Up @@ -180,6 +185,10 @@ def text_and_links_in_email(email)
visit links_in_email(current_email).first
end

When /^(?:I|they) click the second link in the email$/ do
visit links_in_email(current_email).second
end

#
# Debugging
# These only work with Rails and OSx ATM since EmailViewer uses RAILS_ROOT and OSx's 'open' command.
Expand Down

0 comments on commit 6174356

Please sign in to comment.