Skip to content

Commit 8131b64

Browse files
committed
Merge branch '52477-add-iid-headers-to-emails' into 'master'
Add IID headers to E-Mail notifications Closes #52477 See merge request gitlab-org/gitlab-ce!22263
2 parents 8364398 + 2063dcf commit 8131b64

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

app/mailers/notify.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ def mail_thread(model, headers = {})
118118
add_unsubscription_headers_and_links
119119

120120
headers["X-GitLab-#{model.class.name}-ID"] = model.id
121+
headers["X-GitLab-#{model.class.name}-IID"] = model.iid if model.respond_to?(:iid)
121122
headers['X-GitLab-Reply-Key'] = reply_key
122123

123124
@reason = headers['X-GitLab-NotificationReason']
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
title: Add IID headers to E-Mail notifications
3+
merge_request: 22263
4+
author:
5+
type: changed

spec/support/shared_examples/notify_shared_examples.rb

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,20 @@
4545
end
4646
end
4747

48+
shared_examples 'an email with X-GitLab headers containing IDs' do
49+
it 'has X-GitLab-*-ID header' do
50+
is_expected.to have_header "X-GitLab-#{model.class.name}-ID", "#{model.id}"
51+
end
52+
53+
it 'has X-GitLab-*-IID header if model has iid defined' do
54+
if model.respond_to?(:iid)
55+
is_expected.to have_header "X-GitLab-#{model.class.name}-IID", "#{model.iid}"
56+
else
57+
expect(subject.header["X-GitLab-#{model.class.name}-IID"]).to eq nil
58+
end
59+
end
60+
end
61+
4862
shared_examples 'an email with X-GitLab headers containing project details' do
4963
it 'has X-GitLab-Project headers' do
5064
aggregate_failures do
@@ -69,6 +83,7 @@
6983

7084
shared_examples 'a thread answer email with reply-by-email enabled' do
7185
include_examples 'an email with X-GitLab headers containing project details'
86+
include_examples 'an email with X-GitLab headers containing IDs'
7287

7388
it 'has the characteristics of a threaded reply' do
7489
host = Gitlab.config.gitlab.host
@@ -85,6 +100,7 @@
85100

86101
shared_examples 'an email starting a new thread with reply-by-email enabled' do
87102
include_examples 'an email with X-GitLab headers containing project details'
103+
include_examples 'an email with X-GitLab headers containing IDs'
88104
include_examples 'a new thread email with reply-by-email enabled'
89105

90106
it 'includes "Reply to this email directly or <View it on GitLab>"' do
@@ -109,6 +125,7 @@
109125

110126
shared_examples 'an answer to an existing thread with reply-by-email enabled' do
111127
include_examples 'an email with X-GitLab headers containing project details'
128+
include_examples 'an email with X-GitLab headers containing IDs'
112129
include_examples 'a thread answer email with reply-by-email enabled'
113130

114131
context 'when reply-by-email is enabled with incoming address with %{key}' do

0 commit comments

Comments
 (0)