Commit 67ae8adc authored by Gabriel Mazetto's avatar Gabriel Mazetto

Fixed MailRoom specs and make sure it works with new resque.yml format

Some codestyle changes
parent 6f318795
...@@ -14,6 +14,10 @@ module Gitlab ...@@ -14,6 +14,10 @@ module Gitlab
@config ||= fetch_config @config ||= fetch_config
end end
def reload_config!
@config = fetch_config
end
private private
def fetch_config def fetch_config
......
...@@ -24,7 +24,7 @@ module Gitlab ...@@ -24,7 +24,7 @@ module Gitlab
# @deprecated Use .params instead to get sentinel support # @deprecated Use .params instead to get sentinel support
def url def url
raw_config_hash[:url] new.url
end end
def with def with
...@@ -45,6 +45,10 @@ module Gitlab ...@@ -45,6 +45,10 @@ module Gitlab
redis_store_options redis_store_options
end end
def url
raw_config_hash[:url]
end
private private
def redis_store_options def redis_store_options
......
require "spec_helper" require 'spec_helper'
describe "mail_room.yml" do describe 'mail_room.yml' do
let(:config_path) { "config/mail_room.yml" } let(:config_path) { 'config/mail_room.yml' }
let(:configuration) { YAML.load(ERB.new(File.read(config_path)).result) } let(:configuration) { YAML.load(ERB.new(File.read(config_path)).result) }
context "when incoming email is disabled" do context 'when incoming email is disabled' do
before do before do
ENV["MAIL_ROOM_GITLAB_CONFIG_FILE"] = Rails.root.join("spec/fixtures/mail_room_disabled.yml").to_s ENV['MAIL_ROOM_GITLAB_CONFIG_FILE'] = Rails.root.join('spec/fixtures/mail_room_disabled.yml').to_s
Gitlab::MailRoom.reload_config!
end end
after do after do
ENV["MAIL_ROOM_GITLAB_CONFIG_FILE"] = nil ENV['MAIL_ROOM_GITLAB_CONFIG_FILE'] = nil
end end
it "contains no configuration" do it 'contains no configuration' do
expect(configuration[:mailboxes]).to be_nil expect(configuration[:mailboxes]).to be_nil
end end
end end
context "when incoming email is enabled" do context 'when incoming email is enabled' do
before do before do
ENV["MAIL_ROOM_GITLAB_CONFIG_FILE"] = Rails.root.join("spec/fixtures/mail_room_enabled.yml").to_s ENV['MAIL_ROOM_GITLAB_CONFIG_FILE'] = Rails.root.join('spec/fixtures/mail_room_enabled.yml').to_s
Gitlab::MailRoom.reload_config!
end end
after do after do
ENV["MAIL_ROOM_GITLAB_CONFIG_FILE"] = nil ENV['MAIL_ROOM_GITLAB_CONFIG_FILE'] = nil
end end
it "contains the intended configuration" do it 'contains the intended configuration' do
expect(configuration[:mailboxes].length).to eq(1) expect(configuration[:mailboxes].length).to eq(1)
mailbox = configuration[:mailboxes].first mailbox = configuration[:mailboxes].first
expect(mailbox[:host]).to eq("imap.gmail.com") expect(mailbox[:host]).to eq('imap.gmail.com')
expect(mailbox[:port]).to eq(993) expect(mailbox[:port]).to eq(993)
expect(mailbox[:ssl]).to eq(true) expect(mailbox[:ssl]).to eq(true)
expect(mailbox[:start_tls]).to eq(false) expect(mailbox[:start_tls]).to eq(false)
expect(mailbox[:email]).to eq("gitlab-incoming@gmail.com") expect(mailbox[:email]).to eq('gitlab-incoming@gmail.com')
expect(mailbox[:password]).to eq("[REDACTED]") expect(mailbox[:password]).to eq('[REDACTED]')
expect(mailbox[:name]).to eq("inbox") expect(mailbox[:name]).to eq('inbox')
redis_config_file = Rails.root.join('config', 'resque.yml') redis_url = Gitlab::Redis.url
redis_url =
if File.exist?(redis_config_file)
YAML.load_file(redis_config_file)[Rails.env]
else
"redis://localhost:6379"
end
expect(mailbox[:delivery_options][:redis_url]).to eq(redis_url) expect(mailbox[:delivery_options][:redis_url]).to eq(redis_url)
expect(mailbox[:arbitration_options][:redis_url]).to eq(redis_url) expect(mailbox[:arbitration_options][:redis_url]).to eq(redis_url)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment