diff options
author | Douwe Maan <douwe@gitlab.com> | 2017-10-31 10:24:29 +0000 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2017-10-31 10:24:29 +0000 |
commit | 7e78db6e04c3760c90d676e9a797b1b16b1dff7b (patch) | |
tree | 7bbe33a6808b75eecf1f5afe37495fe4f6f4be1c | |
parent | e25acf24baf365f66c65a9dc3fdc8bc49b9546de (diff) | |
parent | eddc9e41a6df94e55f9df91241a83e2ae3439c49 (diff) | |
download | gitlab-ce-7e78db6e04c3760c90d676e9a797b1b16b1dff7b.tar.gz |
Merge branch '39593-emails-on-push-are-sent-to-only-the-first-recipient-when-using-aws-ses' into 'master'
Resolve "Emails on Push are sent to only the first recipient when using AWS SES"
Closes #39593
See merge request gitlab-org/gitlab-ce!15083
3 files changed, 26 insertions, 6 deletions
diff --git a/changelogs/unreleased/39593-emails-on-push-are-sent-to-only-the-first-recipient-when-using-aws-ses.yml b/changelogs/unreleased/39593-emails-on-push-are-sent-to-only-the-first-recipient-when-using-aws-ses.yml new file mode 100644 index 00000000000..9a7109d054e --- /dev/null +++ b/changelogs/unreleased/39593-emails-on-push-are-sent-to-only-the-first-recipient-when-using-aws-ses.yml @@ -0,0 +1,5 @@ +--- +title: Only set Auto-Submitted header once for emails on push +merge_request: +author: +type: fixed diff --git a/lib/additional_email_headers_interceptor.rb b/lib/additional_email_headers_interceptor.rb index 2358fa6bbfd..3cb1694b9f1 100644 --- a/lib/additional_email_headers_interceptor.rb +++ b/lib/additional_email_headers_interceptor.rb @@ -1,8 +1,6 @@ class AdditionalEmailHeadersInterceptor def self.delivering_email(message) - message.headers( - 'Auto-Submitted' => 'auto-generated', - 'X-Auto-Response-Suppress' => 'All' - ) + message.header['Auto-Submitted'] ||= 'auto-generated' + message.header['X-Auto-Response-Suppress'] ||= 'All' end end diff --git a/spec/lib/additional_email_headers_interceptor_spec.rb b/spec/lib/additional_email_headers_interceptor_spec.rb index 580450eef1e..b5c1a360ba9 100644 --- a/spec/lib/additional_email_headers_interceptor_spec.rb +++ b/spec/lib/additional_email_headers_interceptor_spec.rb @@ -1,12 +1,29 @@ require 'spec_helper' describe AdditionalEmailHeadersInterceptor do - it 'adds Auto-Submitted header' do - mail = ActionMailer::Base.mail(to: 'test@mail.com', from: 'info@mail.com', body: 'hello').deliver + let(:mail) do + ActionMailer::Base.mail(to: 'test@mail.com', from: 'info@mail.com', body: 'hello') + end + + before do + mail.deliver_now + end + it 'adds Auto-Submitted header' do expect(mail.header['To'].value).to eq('test@mail.com') expect(mail.header['From'].value).to eq('info@mail.com') expect(mail.header['Auto-Submitted'].value).to eq('auto-generated') expect(mail.header['X-Auto-Response-Suppress'].value).to eq('All') end + + context 'when the same mail object is sent twice' do + before do + mail.deliver_now + end + + it 'does not add the Auto-Submitted header twice' do + expect(mail.header['Auto-Submitted'].value).to eq('auto-generated') + expect(mail.header['X-Auto-Response-Suppress'].value).to eq('All') + end + end end |