Set Auto-Submitted: auto-generated header to emails

Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/20305
This commit is contained in:
Semyon Pupkov 2017-02-11 22:30:15 +05:00
parent 5e95296278
commit a89e973626
4 changed files with 25 additions and 0 deletions

View file

@ -0,0 +1,4 @@
---
title: Set Auto-Submitted header to mails
merge_request:
author: Semyon Pupkov

View file

@ -0,0 +1 @@
ActionMailer::Base.register_interceptor(AdditionalEmailHeadersInterceptor)

View file

@ -0,0 +1,8 @@
class AdditionalEmailHeadersInterceptor
def self.delivering_email(message)
message.headers(
'Auto-Submitted' => 'auto-generated',
'X-Auto-Response-Suppress' => 'All'
)
end
end

View file

@ -0,0 +1,12 @@
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
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
end