Commit b35084f8 authored by Rémy Coutable's avatar Rémy Coutable

Fix a few EE-specific fixtures path related issues

Signed-off-by: default avatarRémy Coutable <remy@rymai.me>
parent 65f68427
......@@ -141,7 +141,7 @@ describe Groups::EpicsController do
show_epic(:json)
expect(response).to have_http_status(200)
expect(response).to match_response_schema('entities/epic')
expect(response).to match_response_schema('entities/epic', dir: 'ee')
end
context 'with unauthorized user' do
......
......@@ -8,7 +8,7 @@ describe Gitlab::Email::Handler::EE::ServiceDeskHandler do
stub_config_setting(host: 'localhost')
end
let(:email_raw) { fixture_file('emails/service_desk.eml') }
let(:email_raw) { fixture_file('emails/service_desk.eml', dir: 'ee') }
let(:namespace) { create(:namespace, name: "email") }
context 'service desk is enabled for the project' do
......@@ -64,7 +64,7 @@ describe Gitlab::Email::Handler::EE::ServiceDeskHandler do
end
context 'when the email is forwarded through an alias' do
let(:email_raw) { fixture_file('emails/service_desk_forwarded.eml') }
let(:email_raw) { fixture_file('emails/service_desk_forwarded.eml', dir: 'ee') }
it 'sends thank you the email and creates issue' do
setup_attachment
......
require 'spec_helper'
describe Gitlab::Email::Handler do
before do
stub_incoming_email_setting(enabled: true, address: "incoming+%{key}@appmail.adventuretime.ooo")
stub_config_setting(host: 'localhost')
end
describe '.for' do
def handler_for(fixture, mail_key)
described_class.for(fixture_file(fixture), mail_key)
end
def ee_handler_for(fixture, mail_key)
described_class.for(fixture_file(fixture, dir: 'ee'), mail_key)
end
context 'a Service Desk email' do
it 'uses the Service Desk handler when Service Desk is enabled' do
allow(License).to receive(:feature_available?).and_call_original
allow(License).to receive(:feature_available?).with(:service_desk).and_return(true)
expect(ee_handler_for('emails/service_desk.eml', 'some/project')).to be_instance_of(Gitlab::Email::Handler::EE::ServiceDeskHandler)
end
it 'uses no handler when Service Desk is disabled' do
allow(License).to receive(:feature_available?).and_call_original
allow(License).to receive(:feature_available?).with(:service_desk).and_return(false)
expect(ee_handler_for('emails/service_desk.eml', 'some/project')).to be_nil
end
end
context 'a new issue email' do
let!(:user) { create(:user, email: 'jake@adventuretime.ooo', incoming_email_token: 'auth_token') }
it 'uses the create issue handler when Service Desk is enabled' do
allow(License).to receive(:feature_available?).and_call_original
allow(License).to receive(:feature_available?).with(:service_desk).and_return(true)
expect(handler_for('emails/valid_new_issue.eml', 'some/project+auth_token')).to be_instance_of(Gitlab::Email::Handler::CreateIssueHandler)
end
it 'uses the create issue handler when Service Desk is disabled' do
allow(License).to receive(:feature_available?).and_call_original
allow(License).to receive(:feature_available?).with(:service_desk).and_return(false)
expect(handler_for('emails/valid_new_issue.eml', 'some/project+auth_token')).to be_instance_of(Gitlab::Email::Handler::CreateIssueHandler)
end
end
end
end
......@@ -33,7 +33,7 @@ describe SystemCheck::Geo::AuthorizedKeysCheck do
it 'skips when config file is not readable' do
override_sshd_config('system_check/sshd_config')
allow(File).to receive(:readable?).with(expand_fixture_ee_path('system_check/sshd_config')) { false }
allow(File).to receive(:readable?).with(expand_fixture_path('system_check/sshd_config', dir: 'ee')) { false }
expect_skipped('Cannot access OpenSSH configuration file')
......@@ -167,6 +167,6 @@ describe SystemCheck::Geo::AuthorizedKeysCheck do
end
def override_sshd_config(relative_path)
allow(subject).to receive(:openssh_config_path) { expand_fixture_ee_path(relative_path) }
allow(subject).to receive(:openssh_config_path) { expand_fixture_path(relative_path, dir: 'ee') }
end
end
......@@ -56,7 +56,7 @@ describe API::V3::Github do
expect(json_response).to be_an(Array)
expect(json_response.size).to eq(2)
expect(response).to match_response_schema('entities/github/repositories')
expect(response).to match_response_schema('entities/github/repositories', dir: 'ee')
end
it 'returns valid project path as name' do
......@@ -104,7 +104,7 @@ describe API::V3::Github do
expect(response).to include_pagination_headers
expect(json_response).to be_an(Array)
expect(response).to match_response_schema('entities/github/branches')
expect(response).to match_response_schema('entities/github/branches', dir: 'ee')
end
end
......@@ -142,7 +142,7 @@ describe API::V3::Github do
get v3_api("/repos/#{project.namespace.path}/#{project.path}/commits/#{commit_id}", user)
expect(response).to have_gitlab_http_status(200)
expect(response).to match_response_schema('entities/github/commit')
expect(response).to match_response_schema('entities/github/commit', dir: 'ee')
end
end
......
......@@ -16,7 +16,7 @@ describe Ci::RegisterJobService do
context 'allow to pick builds' do
let(:build) { execute(shared_runner) }
it { expect(build).to be_kind_of(Build) }
it { expect(build).to be_kind_of(Ci::Build) }
end
context 'when over the global quota' do
......@@ -37,7 +37,7 @@ describe Ci::RegisterJobService do
end
it "does return the build" do
expect(build).to be_kind_of(Build)
expect(build).to be_kind_of(Ci::Build)
end
end
......@@ -47,7 +47,7 @@ describe Ci::RegisterJobService do
end
it "does return the build" do
expect(build).to be_kind_of(Build)
expect(build).to be_kind_of(Ci::Build)
end
end
......@@ -57,7 +57,7 @@ describe Ci::RegisterJobService do
end
it "does return the build" do
expect(build).to be_kind_of(Build)
expect(build).to be_kind_of(Ci::Build)
end
end
end
......
require 'spec_helper'
describe Gitlab::Email::Handler do
before do
stub_incoming_email_setting(enabled: true, address: "incoming+%{key}@appmail.adventuretime.ooo")
stub_config_setting(host: 'localhost')
end
describe '.for' do
it 'picks issue handler if there is not merge request prefix' do
expect(described_class.for('email', 'project+key')).to be_an_instance_of(Gitlab::Email::Handler::CreateIssueHandler)
......@@ -18,43 +13,5 @@ describe Gitlab::Email::Handler do
it 'returns nil if no handler is found' do
expect(described_class.for('email', '')).to be_nil
end
def handler_for(fixture, mail_key)
described_class.for(fixture_file(fixture), mail_key)
end
context 'a Service Desk email' do
it 'uses the Service Desk handler when Service Desk is enabled' do
allow(License).to receive(:feature_available?).and_call_original
allow(License).to receive(:feature_available?).with(:service_desk).and_return(true)
expect(handler_for('emails/service_desk.eml', 'some/project')).to be_instance_of(Gitlab::Email::Handler::EE::ServiceDeskHandler)
end
it 'uses no handler when Service Desk is disabled' do
allow(License).to receive(:feature_available?).and_call_original
allow(License).to receive(:feature_available?).with(:service_desk).and_return(false)
expect(handler_for('emails/service_desk.eml', 'some/project')).to be_nil
end
end
context 'a new issue email' do
let!(:user) { create(:user, email: 'jake@adventuretime.ooo', incoming_email_token: 'auth_token') }
it 'uses the create issue handler when Service Desk is enabled' do
allow(License).to receive(:feature_available?).and_call_original
allow(License).to receive(:feature_available?).with(:service_desk).and_return(true)
expect(handler_for('emails/valid_new_issue.eml', 'some/project+auth_token')).to be_instance_of(Gitlab::Email::Handler::CreateIssueHandler)
end
it 'uses the create issue handler when Service Desk is disabled' do
allow(License).to receive(:feature_available?).and_call_original
allow(License).to receive(:feature_available?).with(:service_desk).and_return(false)
expect(handler_for('emails/valid_new_issue.eml', 'some/project+auth_token')).to be_instance_of(Gitlab::Email::Handler::CreateIssueHandler)
end
end
end
end
module FixtureHelpers
def fixture_file(filename)
def fixture_file(filename, dir: '')
return '' if filename.blank?
File.read(expand_fixture_path(filename))
File.read(expand_fixture_path(filename, dir: dir))
end
def fixture_file_ee(filename)
return '' if filename.blank?
File.read(expand_fixture_ee_path(filename))
end
def expand_fixture_path(filename)
File.expand_path(Rails.root.join('spec/fixtures/', filename))
end
def expand_fixture_ee_path(filename)
File.expand_path(Rails.root.join('ee/spec/fixtures/', filename))
def expand_fixture_path(filename, dir: '')
File.expand_path(Rails.root.join(dir, 'spec', 'fixtures', filename))
end
end
......
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