2016-07-09 11:13:19 -04:00
|
|
|
require 'spec_helper'
|
2016-02-26 21:48:13 -05:00
|
|
|
|
2016-07-09 11:13:19 -04:00
|
|
|
describe 'mail_room.yml' do
|
|
|
|
let(:config_path) { 'config/mail_room.yml' }
|
2016-02-26 21:48:13 -05:00
|
|
|
let(:configuration) { YAML.load(ERB.new(File.read(config_path)).result) }
|
2016-10-25 09:50:41 -04:00
|
|
|
before(:each) { clear_raw_config }
|
|
|
|
after(:each) { clear_raw_config }
|
2016-02-26 21:48:13 -05:00
|
|
|
|
2016-07-09 11:13:19 -04:00
|
|
|
context 'when incoming email is disabled' do
|
2016-02-26 21:48:13 -05:00
|
|
|
before do
|
2016-07-09 11:13:19 -04:00
|
|
|
ENV['MAIL_ROOM_GITLAB_CONFIG_FILE'] = Rails.root.join('spec/fixtures/mail_room_disabled.yml').to_s
|
2016-08-04 12:55:24 -04:00
|
|
|
Gitlab::MailRoom.reset_config!
|
2016-02-26 21:48:13 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
after do
|
2016-07-09 11:13:19 -04:00
|
|
|
ENV['MAIL_ROOM_GITLAB_CONFIG_FILE'] = nil
|
2016-02-26 21:48:13 -05:00
|
|
|
end
|
|
|
|
|
2016-07-09 11:13:19 -04:00
|
|
|
it 'contains no configuration' do
|
2016-02-26 21:48:13 -05:00
|
|
|
expect(configuration[:mailboxes]).to be_nil
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-07-09 11:13:19 -04:00
|
|
|
context 'when incoming email is enabled' do
|
2016-10-25 09:50:41 -04:00
|
|
|
let(:redis_config) { Rails.root.join('spec/fixtures/config/redis_new_format_host.yml') }
|
|
|
|
let(:gitlab_redis) { Gitlab::Redis.new(Rails.env) }
|
|
|
|
|
2016-02-26 21:48:13 -05:00
|
|
|
before do
|
2016-07-09 11:13:19 -04:00
|
|
|
ENV['MAIL_ROOM_GITLAB_CONFIG_FILE'] = Rails.root.join('spec/fixtures/mail_room_enabled.yml').to_s
|
2016-08-04 12:55:24 -04:00
|
|
|
Gitlab::MailRoom.reset_config!
|
2016-02-26 21:48:13 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
after do
|
2016-07-09 11:13:19 -04:00
|
|
|
ENV['MAIL_ROOM_GITLAB_CONFIG_FILE'] = nil
|
2016-02-26 21:48:13 -05:00
|
|
|
end
|
|
|
|
|
2016-07-09 11:13:19 -04:00
|
|
|
it 'contains the intended configuration' do
|
2016-10-25 09:50:41 -04:00
|
|
|
stub_const('Gitlab::Redis::CONFIG_FILE', redis_config)
|
2016-02-26 21:48:13 -05:00
|
|
|
|
2016-10-25 09:50:41 -04:00
|
|
|
expect(configuration[:mailboxes].length).to eq(1)
|
2016-02-26 21:48:13 -05:00
|
|
|
mailbox = configuration[:mailboxes].first
|
|
|
|
|
2016-07-09 11:13:19 -04:00
|
|
|
expect(mailbox[:host]).to eq('imap.gmail.com')
|
2016-02-26 21:48:13 -05:00
|
|
|
expect(mailbox[:port]).to eq(993)
|
|
|
|
expect(mailbox[:ssl]).to eq(true)
|
|
|
|
expect(mailbox[:start_tls]).to eq(false)
|
2016-07-09 11:13:19 -04:00
|
|
|
expect(mailbox[:email]).to eq('gitlab-incoming@gmail.com')
|
|
|
|
expect(mailbox[:password]).to eq('[REDACTED]')
|
|
|
|
expect(mailbox[:name]).to eq('inbox')
|
|
|
|
|
2016-10-25 09:50:41 -04:00
|
|
|
redis_url = gitlab_redis.url
|
|
|
|
sentinels = gitlab_redis.sentinels
|
2016-02-26 21:48:13 -05:00
|
|
|
|
2016-10-25 09:50:41 -04:00
|
|
|
expect(mailbox[:delivery_options][:redis_url]).to be_present
|
2016-02-26 21:48:13 -05:00
|
|
|
expect(mailbox[:delivery_options][:redis_url]).to eq(redis_url)
|
2016-10-25 09:50:41 -04:00
|
|
|
|
|
|
|
expect(mailbox[:delivery_options][:sentinels]).to be_present
|
|
|
|
expect(mailbox[:delivery_options][:sentinels]).to eq(sentinels)
|
|
|
|
|
|
|
|
expect(mailbox[:arbitration_options][:redis_url]).to be_present
|
2016-02-26 21:48:13 -05:00
|
|
|
expect(mailbox[:arbitration_options][:redis_url]).to eq(redis_url)
|
2016-10-25 09:50:41 -04:00
|
|
|
|
|
|
|
expect(mailbox[:arbitration_options][:sentinels]).to be_present
|
|
|
|
expect(mailbox[:arbitration_options][:sentinels]).to eq(sentinels)
|
2016-02-26 21:48:13 -05:00
|
|
|
end
|
|
|
|
end
|
2016-10-25 09:50:41 -04:00
|
|
|
|
|
|
|
def clear_raw_config
|
|
|
|
Gitlab::Redis.remove_instance_variable(:@_raw_config)
|
|
|
|
rescue NameError
|
|
|
|
# raised if @_raw_config was not set; ignore
|
|
|
|
end
|
2016-02-26 21:48:13 -05:00
|
|
|
end
|