Commit 3e4d0c3a authored by Rémy Coutable's avatar Rémy Coutable

Reduce CE/EE diff in spec/controllers/projects/settings/integrations_controller_spec.rb

Signed-off-by: default avatarRémy Coutable <remy@rymai.me>
parent 6668669d
require 'spec_helper'
describe Projects::Settings::IntegrationsController do
let(:project) { create(:project, :public) }
let(:user) { create(:user) }
before do
project.add_master(user)
sign_in(user)
end
shared_examples 'endpoint with some disabled services' do
it 'has some disabled services' do
get :show, namespace_id: project.namespace, project_id: project
expect(active_services).not_to include(*disabled_services)
end
end
shared_examples 'endpoint without disabled services' do
it 'does not have disabled services' do
get :show, namespace_id: project.namespace, project_id: project
expect(active_services).to include(*disabled_services)
end
end
context 'Sets correct services list' do
let(:active_services) { assigns(:services).map(&:type) }
let(:disabled_services) { %w(JenkinsService JenkinsDeprecatedService) }
it 'enables SlackSlashCommandsService and disables GitlabSlackApplication' do
get :show, namespace_id: project.namespace, project_id: project
expect(active_services).to include('SlackSlashCommandsService')
expect(active_services).not_to include('GitlabSlackApplicationService')
end
it 'enables GitlabSlackApplication and disables SlackSlashCommandsService' do
stub_application_setting(slack_app_enabled: true)
allow(::Gitlab).to receive(:com?).and_return(true)
get :show, namespace_id: project.namespace, project_id: project
expect(active_services).to include('GitlabSlackApplicationService')
expect(active_services).not_to include('SlackSlashCommandsService')
end
context 'without a license key' do
before do
License.destroy_all
end
it_behaves_like 'endpoint with some disabled services'
end
context 'with a license key' do
let(:namespace) { create(:group, :private) }
let(:project) { create(:project, :private, namespace: namespace) }
context 'when checking of namespace plan is enabled' do
before do
allow(Gitlab::CurrentSettings.current_application_settings).to receive(:should_check_namespace_plan?) { true }
end
context 'and namespace does not have a plan' do
it_behaves_like 'endpoint with some disabled services'
end
context 'and namespace has a plan' do
let(:namespace) { create(:group, :private, plan: :bronze_plan) }
it_behaves_like 'endpoint without disabled services'
end
end
context 'when checking of namespace plan is not enabled' do
before do
allow(Gitlab::CurrentSettings.current_application_settings).to receive(:should_check_namespace_plan?) { false }
end
it_behaves_like 'endpoint without disabled services'
end
end
end
end
......@@ -17,79 +17,4 @@ describe Projects::Settings::IntegrationsController do
expect(response).to render_template(:show)
end
end
shared_examples 'endpoint with some disabled services' do
it 'has some disabled services' do
get :show, namespace_id: project.namespace, project_id: project
expect(active_services).not_to include(*disabled_services)
end
end
shared_examples 'endpoint without disabled services' do
it 'does not have disabled services' do
get :show, namespace_id: project.namespace, project_id: project
expect(active_services).to include(*disabled_services)
end
end
context 'Sets correct services list' do
let(:active_services) { assigns(:services).map(&:type) }
let(:disabled_services) { %w(JenkinsService JenkinsDeprecatedService) }
it 'enables SlackSlashCommandsService and disables GitlabSlackApplication' do
get :show, namespace_id: project.namespace, project_id: project
expect(active_services).to include('SlackSlashCommandsService')
expect(active_services).not_to include('GitlabSlackApplicationService')
end
it 'enables GitlabSlackApplication and disables SlackSlashCommandsService' do
stub_application_setting(slack_app_enabled: true)
allow(::Gitlab).to receive(:com?).and_return(true)
get :show, namespace_id: project.namespace, project_id: project
expect(active_services).to include('GitlabSlackApplicationService')
expect(active_services).not_to include('SlackSlashCommandsService')
end
context 'without a license key' do
before do
License.destroy_all
end
it_behaves_like 'endpoint with some disabled services'
end
context 'with a license key' do
let(:namespace) { create(:group, :private) }
let(:project) { create(:project, :private, namespace: namespace) }
context 'when checking of namespace plan is enabled' do
before do
allow(Gitlab::CurrentSettings.current_application_settings).to receive(:should_check_namespace_plan?) { true }
end
context 'and namespace does not have a plan' do
it_behaves_like 'endpoint with some disabled services'
end
context 'and namespace has a plan' do
let(:namespace) { create(:group, :private, plan: :bronze_plan) }
it_behaves_like 'endpoint without disabled services'
end
end
context 'when checking of namespace plan is not enabled' do
before do
allow(Gitlab::CurrentSettings.current_application_settings).to receive(:should_check_namespace_plan?) { false }
end
it_behaves_like 'endpoint without disabled services'
end
end
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