Commit 613a13d4 authored by Ash McKenzie's avatar Ash McKenzie

Merge branch '13961-slack-application-integration-only-at-project-level' into 'master'

Slack Application only available at project level

See merge request gitlab-org/gitlab!45192
parents 14c0ac9a 84cb44c3
......@@ -1340,7 +1340,8 @@ class Project < ApplicationRecord
end
def find_or_initialize_services
available_services_names = Service.available_services_names - disabled_services
available_services_names =
Service.available_services_names + Service.project_specific_services_names - disabled_services
available_services_names.map do |service_name|
find_or_initialize_service(service_name)
......
......@@ -208,6 +208,10 @@ class Service < ApplicationRecord
DEV_SERVICE_NAMES
end
def self.project_specific_services_names
[]
end
def self.available_services_types
available_services_names.map { |service_name| "#{service_name}_service".camelize }
end
......
......@@ -9,7 +9,7 @@ module EE
jenkins
].freeze
EE_DEV_SERVICE_NAMES = %w[
EE_PROJECT_SPECIFIC_SERVICE_NAMES = %w[
gitlab_slack_application
].freeze
......@@ -18,24 +18,14 @@ module EE
override :services_names
def services_names
super + ee_services_names
super + EE_SERVICE_NAMES
end
override :dev_services_names
def dev_services_names
return [] unless ::Gitlab.dev_env_or_com?
override :project_specific_services_names
def project_specific_services_names
return super unless ::Gitlab.dev_env_or_com?
super + ee_dev_services_names
end
private
def ee_services_names
EE_SERVICE_NAMES
end
def ee_dev_services_names
EE_DEV_SERVICE_NAMES
super + EE_PROJECT_SPECIFIC_SERVICE_NAMES
end
end
end
......
......@@ -5,12 +5,30 @@ require 'spec_helper'
RSpec.describe Service do
describe 'Available services' do
let(:ee_services) do
%w(
%w[
github
jenkins
)
]
end
it { expect(described_class.available_services_names).to include(*ee_services) }
end
describe '.project_specific_services_names' do
before do
allow(::Gitlab).to receive(:dev_env_or_com?).and_return(dev_env_or_com)
end
context 'when not on gitlab.com and not in development environment' do
let(:dev_env_or_com) { false }
it { expect(described_class.project_specific_services_names).to eq([]) }
end
context 'when on gitlab.com or in dev environment' do
let(:dev_env_or_com) { true }
it { expect(described_class.project_specific_services_names).to eq(%w[gitlab_slack_application]) }
end
end
end
......@@ -5509,12 +5509,13 @@ RSpec.describe Project do
describe '#find_or_initialize_services' do
it 'returns only enabled services' do
allow(Service).to receive(:available_services_names).and_return(%w[prometheus pushover teamcity])
allow(Service).to receive(:project_specific_services_names).and_return(%w[asana])
allow(subject).to receive(:disabled_services).and_return(%w[prometheus])
services = subject.find_or_initialize_services
expect(services.count).to eq(2)
expect(services.map(&:title)).to eq(['JetBrains TeamCity CI', 'Pushover'])
expect(services.count).to eq(3)
expect(services.map(&:title)).to eq(['Asana', 'JetBrains TeamCity CI', 'Pushover'])
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