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 ...@@ -1340,7 +1340,8 @@ class Project < ApplicationRecord
end end
def find_or_initialize_services 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| available_services_names.map do |service_name|
find_or_initialize_service(service_name) find_or_initialize_service(service_name)
......
...@@ -208,6 +208,10 @@ class Service < ApplicationRecord ...@@ -208,6 +208,10 @@ class Service < ApplicationRecord
DEV_SERVICE_NAMES DEV_SERVICE_NAMES
end end
def self.project_specific_services_names
[]
end
def self.available_services_types def self.available_services_types
available_services_names.map { |service_name| "#{service_name}_service".camelize } available_services_names.map { |service_name| "#{service_name}_service".camelize }
end end
......
...@@ -9,7 +9,7 @@ module EE ...@@ -9,7 +9,7 @@ module EE
jenkins jenkins
].freeze ].freeze
EE_DEV_SERVICE_NAMES = %w[ EE_PROJECT_SPECIFIC_SERVICE_NAMES = %w[
gitlab_slack_application gitlab_slack_application
].freeze ].freeze
...@@ -18,24 +18,14 @@ module EE ...@@ -18,24 +18,14 @@ module EE
override :services_names override :services_names
def services_names def services_names
super + ee_services_names super + EE_SERVICE_NAMES
end end
override :dev_services_names override :project_specific_services_names
def dev_services_names def project_specific_services_names
return [] unless ::Gitlab.dev_env_or_com? return super unless ::Gitlab.dev_env_or_com?
super + ee_dev_services_names super + EE_PROJECT_SPECIFIC_SERVICE_NAMES
end
private
def ee_services_names
EE_SERVICE_NAMES
end
def ee_dev_services_names
EE_DEV_SERVICE_NAMES
end end
end end
end end
......
...@@ -5,12 +5,30 @@ require 'spec_helper' ...@@ -5,12 +5,30 @@ require 'spec_helper'
RSpec.describe Service do RSpec.describe Service do
describe 'Available services' do describe 'Available services' do
let(:ee_services) do let(:ee_services) do
%w( %w[
github github
jenkins jenkins
) ]
end end
it { expect(described_class.available_services_names).to include(*ee_services) } it { expect(described_class.available_services_names).to include(*ee_services) }
end 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 end
...@@ -5509,12 +5509,13 @@ RSpec.describe Project do ...@@ -5509,12 +5509,13 @@ RSpec.describe Project do
describe '#find_or_initialize_services' do describe '#find_or_initialize_services' do
it 'returns only enabled 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(: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]) allow(subject).to receive(:disabled_services).and_return(%w[prometheus])
services = subject.find_or_initialize_services services = subject.find_or_initialize_services
expect(services.count).to eq(2) expect(services.count).to eq(3)
expect(services.map(&:title)).to eq(['JetBrains TeamCity CI', 'Pushover']) expect(services.map(&:title)).to eq(['Asana', 'JetBrains TeamCity CI', 'Pushover'])
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