Commit af3c1951 authored by John Hope's avatar John Hope

Excludes project-only services from the admin service templates area

Introduces project_only method to the Service class that defaults to
false. When overridden in a subclass that service will not appear in
the list of service templates that can be set instance-wide.

Fixes a bug where the Generic Alerts Integration appeared at the top
of the list and produced an exception when clicked.
parent 8ef52591
......@@ -7,7 +7,7 @@ class Admin::ServicesController < Admin::ApplicationController
before_action :service, only: [:edit, :update]
def index
@services = services_templates
@services = services_templates.reject(&:project_only?)
end
def edit
......
......@@ -330,6 +330,11 @@ class Service < ApplicationRecord
false
end
# Override for services supported at project level only
def project_only?
false
end
private
def cache_project_has_external_issue_tracker
......
......@@ -58,6 +58,10 @@ class AlertsService < Service
super || build_data
end
def project_only?
true
end
private
def prevent_token_assignment
......
......@@ -106,4 +106,8 @@ describe AlertsService do
it_behaves_like 'valid token'
end
end
describe '#project_only?' do
it { expect(service).to be_project_only }
end
end
......@@ -9,6 +9,15 @@ describe Admin::ServicesController do
sign_in(admin)
end
describe 'GET #index' do
it 'does not show project_only services' do
get :index
expect(assigns(:services)).not_to include(be_project_only),
"expected to exclude project_only services"
end
end
describe 'GET #edit' do
let!(:project) { create(:project) }
......
......@@ -399,6 +399,12 @@ describe Service do
end
end
describe '#project_only?' do
let(:service) { build_stubbed(:service, template: true) }
it { expect(service).not_to be_project_only }
end
describe '#api_field_names' do
let(:fake_service) do
Class.new(Service) do
......
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