2017-02-11 12:30:15 -05:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe AdditionalEmailHeadersInterceptor do
|
2017-10-30 09:50:19 -04:00
|
|
|
let(:mail) do
|
|
|
|
ActionMailer::Base.mail(to: 'test@mail.com', from: 'info@mail.com', body: 'hello')
|
|
|
|
end
|
|
|
|
|
|
|
|
before do
|
|
|
|
mail.deliver_now
|
|
|
|
end
|
2017-02-11 12:30:15 -05:00
|
|
|
|
2017-10-30 09:50:19 -04:00
|
|
|
it 'adds Auto-Submitted header' do
|
2017-02-11 12:30:15 -05:00
|
|
|
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
|
2017-10-30 09:50:19 -04:00
|
|
|
|
|
|
|
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
|
2017-02-11 12:30:15 -05:00
|
|
|
end
|