summaryrefslogtreecommitdiff
path: root/spec/lib/system_check/incoming_email/imap_authentication_check_spec.rb
blob: 9c4aebaedd82292c64048178d94a4eb0186484fc (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
30
31
# frozen_string_literal: true

require 'spec_helper'

MAIL_ROOM_CONFIG_ENABLED_SAMPLE =
  ":mailboxes:\n"\
  "  \n"\
  "    -\n"\
  "      :host: \"gitlab.example.com\"\n"\
  "      :port: 143\n"\
  ""

RSpec.describe SystemCheck::IncomingEmail::ImapAuthenticationCheck do
  subject(:system_check) { described_class.new }

  describe '#load_config' do
    subject { system_check.send(:load_config) }

    context 'returns no mailbox configurations with mailroom default configuration' do
      it { is_expected.to be_nil }
    end

    context 'returns an array of mailbox configurations with mailroom configured' do
      before do
        allow(File).to receive(:read).and_return(MAIL_ROOM_CONFIG_ENABLED_SAMPLE)
      end

      it { is_expected.to eq([{ host: "gitlab.example.com", port: 143 }]) }
    end
  end
end