BigW Consortium Gitlab

mail_room_spec.rb 1.5 KB
Newer Older
1
require 'spec_helper'
2

3 4
describe 'mail_room.yml' do
  let(:config_path)   { 'config/mail_room.yml' }
5 6
  let(:configuration) { YAML.load(ERB.new(File.read(config_path)).result) }

7
  context 'when incoming email is disabled' do
8
    before do
9
      ENV['MAIL_ROOM_GITLAB_CONFIG_FILE'] = Rails.root.join('spec/fixtures/mail_room_disabled.yml').to_s
10
      Gitlab::MailRoom.reset_config!
11 12 13
    end

    after do
14
      ENV['MAIL_ROOM_GITLAB_CONFIG_FILE'] = nil
15 16
    end

17
    it 'contains no configuration' do
18 19 20 21
      expect(configuration[:mailboxes]).to be_nil
    end
  end

22
  context 'when incoming email is enabled' do
23
    before do
24
      ENV['MAIL_ROOM_GITLAB_CONFIG_FILE'] = Rails.root.join('spec/fixtures/mail_room_enabled.yml').to_s
25
      Gitlab::MailRoom.reset_config!
26 27 28
    end

    after do
29
      ENV['MAIL_ROOM_GITLAB_CONFIG_FILE'] = nil
30 31
    end

32
    it 'contains the intended configuration' do
33 34 35 36
      expect(configuration[:mailboxes].length).to eq(1)

      mailbox = configuration[:mailboxes].first

37
      expect(mailbox[:host]).to eq('imap.gmail.com')
38 39 40
      expect(mailbox[:port]).to eq(993)
      expect(mailbox[:ssl]).to eq(true)
      expect(mailbox[:start_tls]).to eq(false)
41 42 43 44 45
      expect(mailbox[:email]).to eq('gitlab-incoming@gmail.com')
      expect(mailbox[:password]).to eq('[REDACTED]')
      expect(mailbox[:name]).to eq('inbox')

      redis_url = Gitlab::Redis.url
46 47 48 49 50 51

      expect(mailbox[:delivery_options][:redis_url]).to eq(redis_url)
      expect(mailbox[:arbitration_options][:redis_url]).to eq(redis_url)
    end
  end
end