summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean McGivern <sean@gitlab.com>2016-09-25 17:06:09 +0100
committerSean McGivern <sean@gitlab.com>2016-09-26 16:01:17 +0100
commit20de47235e39e585ac1c8746fc9c4f673da910a0 (patch)
tree0851be1e2ce9dedc4e46f5e89b5137e3925f38cd
parentc8d92f95954dd37e50af8d7a91271566f00cb25b (diff)
downloadgitlab-ce-fix-unsubscribe-header.tar.gz
Wrap List-Unsubscribe link in angle bracketsfix-unsubscribe-header
-rw-r--r--CHANGELOG1
-rw-r--r--app/mailers/notify.rb2
-rw-r--r--spec/features/unsubscribe_links_spec.rb2
-rw-r--r--spec/mailers/shared/notify.rb3
4 files changed, 5 insertions, 3 deletions
diff --git a/CHANGELOG b/CHANGELOG
index 463b07b635e..0391f5c5e93 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -6,6 +6,7 @@ v 8.13.0 (unreleased)
v 8.12.2 (unreleased)
- Fix Import/Export not recognising correctly the imported services.
+ - Fix List-Unsubscribe header in emails
v 8.12.1
- Fix a memory leak in HTML::Pipeline::SanitizationFilter::WHITELIST
diff --git a/app/mailers/notify.rb b/app/mailers/notify.rb
index 9799f1dc886..29f1c527776 100644
--- a/app/mailers/notify.rb
+++ b/app/mailers/notify.rb
@@ -109,7 +109,7 @@ class Notify < BaseMailer
headers['X-GitLab-Reply-Key'] = reply_key
if !@labels_url && @sent_notification && @sent_notification.unsubscribable?
- headers['List-Unsubscribe'] = unsubscribe_sent_notification_url(@sent_notification, force: true)
+ headers['List-Unsubscribe'] = "<#{unsubscribe_sent_notification_url(@sent_notification, force: true)}>"
@sent_notification_url = unsubscribe_sent_notification_url(@sent_notification)
end
diff --git a/spec/features/unsubscribe_links_spec.rb b/spec/features/unsubscribe_links_spec.rb
index cc40671787c..33b52d1547e 100644
--- a/spec/features/unsubscribe_links_spec.rb
+++ b/spec/features/unsubscribe_links_spec.rb
@@ -11,7 +11,7 @@ describe 'Unsubscribe links', feature: true do
let(:mail) { ActionMailer::Base.deliveries.last }
let(:body) { Capybara::Node::Simple.new(mail.default_part_body.to_s) }
- let(:header_link) { mail.header['List-Unsubscribe'] }
+ let(:header_link) { mail.header['List-Unsubscribe'].to_s[1..-2] } # Strip angle brackets
let(:body_link) { body.find_link('unsubscribe')['href'] }
before do
diff --git a/spec/mailers/shared/notify.rb b/spec/mailers/shared/notify.rb
index 56872da9a8f..5c9851f14c7 100644
--- a/spec/mailers/shared/notify.rb
+++ b/spec/mailers/shared/notify.rb
@@ -169,8 +169,9 @@ shared_examples 'it should show Gmail Actions View Commit link' do
end
shared_examples 'an unsubscribeable thread' do
- it 'has a List-Unsubscribe header' do
+ it 'has a List-Unsubscribe header in the correct format' do
is_expected.to have_header 'List-Unsubscribe', /unsubscribe/
+ is_expected.to have_header 'List-Unsubscribe', /^<.+>$/
end
it { is_expected.to have_body_text /unsubscribe/ }