summaryrefslogtreecommitdiff
path: root/spec/lib/gitlab/email/hook/additional_headers_interceptor_spec.rb
blob: ae61ece8029847beaf3bd6e6f81b368842c2a435 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
require 'spec_helper'

describe Gitlab::Email::Hook::AdditionalHeadersInterceptor do
  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