Commit 70d17486 authored by Kerri Miller's avatar Kerri Miller

Merge branch '238570-hide-instance-level-integrations-on-gitlab-com' into 'master'

Hide instance-level integrations on GitLab.com

See merge request gitlab-org/gitlab!42808
parents 85a21791 a5cea27a
......@@ -2,6 +2,7 @@
class Admin::ApplicationSettingsController < Admin::ApplicationController
include InternalRedirect
include ServicesHelper
# NOTE: Use @application_setting in this controller when you need to access
# application_settings after it has been modified. This is because the
......@@ -32,6 +33,8 @@ class Admin::ApplicationSettingsController < Admin::ApplicationController
end
def integrations
return not_found unless instance_level_integrations?
@integrations = Service.find_or_initialize_all(Service.for_instance).sort_by(&:title)
end
......
......@@ -2,6 +2,7 @@
class Admin::IntegrationsController < Admin::ApplicationController
include IntegrationsActions
include ServicesHelper
private
......@@ -10,7 +11,7 @@ class Admin::IntegrationsController < Admin::ApplicationController
end
def integrations_enabled?
true
instance_level_integrations?
end
def scoped_edit_integration_path(integration)
......
......@@ -124,6 +124,10 @@ module ServicesHelper
@group.present? && Feature.enabled?(:group_level_integrations, @group)
end
def instance_level_integrations?
!Gitlab.com?
end
extend self
private
......
......@@ -260,10 +260,11 @@
= link_to general_admin_application_settings_path, title: _('General'), class: 'qa-admin-settings-general-item' do
%span
= _('General')
= nav_link(path: ['application_settings#integrations', 'integrations#edit']) do
= link_to integrations_admin_application_settings_path, title: _('Integrations'), data: { qa_selector: 'integration_settings_link' } do
%span
= _('Integrations')
- if instance_level_integrations?
= nav_link(path: ['application_settings#integrations', 'integrations#edit']) do
= link_to integrations_admin_application_settings_path, title: _('Integrations'), data: { qa_selector: 'integration_settings_link' } do
%span
= _('Integrations')
= nav_link(path: 'application_settings#repository') do
= link_to repository_admin_application_settings_path, title: _('Repository'), class: 'qa-admin-settings-repository-item' do
%span
......
---
title: Hide instance-level integrations on GitLab.com
merge_request: 42808
author:
type: changed
......@@ -15,6 +15,37 @@ RSpec.describe Admin::ApplicationSettingsController do
stub_env('IN_MEMORY_APPLICATION_SETTINGS', 'false')
end
describe 'GET #integrations' do
before do
sign_in(admin)
end
context 'when GitLab.com' do
before do
allow(::Gitlab).to receive(:com?) { true }
end
it 'returns 404' do
get :integrations
expect(response).to have_gitlab_http_status(:not_found)
end
end
context 'when not GitLab.com' do
before do
allow(::Gitlab).to receive(:com?) { false }
end
it 'renders correct template' do
get :integrations
expect(response).to have_gitlab_http_status(:ok)
expect(response).to render_template('admin/application_settings/integrations')
end
end
end
describe 'GET #usage_data with no access' do
before do
stub_usage_data_connections
......
......@@ -20,6 +20,18 @@ RSpec.describe Admin::IntegrationsController do
end
end
end
context 'when GitLab.com' do
before do
allow(::Gitlab).to receive(:com?) { true }
end
it 'returns 404' do
get :edit, params: { id: Service.available_services_names.sample }
expect(response).to have_gitlab_http_status(:not_found)
end
end
end
describe '#update' do
......
......@@ -92,7 +92,11 @@ RSpec.describe 'layouts/nav/sidebar/_admin' do
end
context 'on settings' do
let(:gitlab_com?) { false }
before do
allow(::Gitlab).to receive(:com?) { gitlab_com? }
render
end
......@@ -100,6 +104,20 @@ RSpec.describe 'layouts/nav/sidebar/_admin' do
expect(rendered).to have_link('General', href: general_admin_application_settings_path)
end
context 'when GitLab.com' do
let(:gitlab_com?) { true }
it 'does not include Integrations link' do
expect(rendered).not_to have_link('Integrations', href: integrations_admin_application_settings_path)
end
end
context 'when not GitLab.com' do
it 'includes Integrations link' do
expect(rendered).to have_link('Integrations', href: integrations_admin_application_settings_path)
end
end
context 'when GitLab FOSS' do
it 'does not include Templates link' do
expect(rendered).not_to have_link('Templates', href: '/admin/application_settings/templates')
......
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