Commit 9787e5e3 authored by Robert May's avatar Robert May

Merge branch 'justin_ho-enable-slack-application-for-development-environment' into 'master'

Enable Slack application on development

See merge request gitlab-org/gitlab!78576
parents 9bdf73a5 38e7b481
...@@ -22,7 +22,7 @@ module EE ...@@ -22,7 +22,7 @@ module EE
override :project_specific_integration_names override :project_specific_integration_names
def project_specific_integration_names def project_specific_integration_names
integrations = super + EE_PROJECT_SPECIFIC_INTEGRATION_NAMES integrations = super + EE_PROJECT_SPECIFIC_INTEGRATION_NAMES
integrations += EE_COM_PROJECT_SPECIFIC_INTEGRATION_NAMES if ::Gitlab.com? integrations += EE_COM_PROJECT_SPECIFIC_INTEGRATION_NAMES if ::Gitlab.dev_env_or_com?
integrations integrations
end end
end end
......
...@@ -658,7 +658,13 @@ module EE ...@@ -658,7 +658,13 @@ module EE
def disabled_integrations def disabled_integrations
strong_memoize(:disabled_integrations) do strong_memoize(:disabled_integrations) do
gh = github_integration_enabled? ? [] : %w[github] gh = github_integration_enabled? ? [] : %w[github]
slack = ::Gitlab::CurrentSettings.slack_app_enabled ? %w[slack_slash_commands] : %w[gitlab_slack_application] slack = if Rails.env.development?
[]
elsif ::Gitlab::CurrentSettings.slack_app_enabled
%w[slack_slash_commands]
else
%w[gitlab_slack_application]
end
super + gh + slack super + gh + slack
end end
......
...@@ -8,6 +8,8 @@ RSpec.describe Integration do ...@@ -8,6 +8,8 @@ RSpec.describe Integration do
end end
describe '.project_specific_integration_names' do describe '.project_specific_integration_names' do
subject { described_class.project_specific_integration_names }
before do before do
allow(::Gitlab).to receive(:com?).and_return(com) allow(::Gitlab).to receive(:com?).and_return(com)
end end
...@@ -15,19 +17,22 @@ RSpec.describe Integration do ...@@ -15,19 +17,22 @@ RSpec.describe Integration do
context 'when not on gitlab.com' do context 'when not on gitlab.com' do
let(:com) { false } let(:com) { false }
it do it { is_expected.to include(*described_class::EE_PROJECT_SPECIFIC_INTEGRATION_NAMES) }
expect(described_class.project_specific_integration_names) it { is_expected.not_to include(*described_class::EE_COM_PROJECT_SPECIFIC_INTEGRATION_NAMES) }
.to include(*described_class::EE_PROJECT_SPECIFIC_INTEGRATION_NAMES)
context 'when on dev' do
before do
allow(Rails.env).to receive(:development?).and_return(true)
end
it { is_expected.to include(*described_class::EE_COM_PROJECT_SPECIFIC_INTEGRATION_NAMES) }
end end
end end
context 'when on gitlab.com' do context 'when on gitlab.com' do
let(:com) { true } let(:com) { true }
it do it { is_expected.to include(*described_class::EE_PROJECT_SPECIFIC_INTEGRATION_NAMES, *Integration::EE_COM_PROJECT_SPECIFIC_INTEGRATION_NAMES) }
expect(described_class.project_specific_integration_names)
.to include(*described_class::EE_PROJECT_SPECIFIC_INTEGRATION_NAMES, *Integration::EE_COM_PROJECT_SPECIFIC_INTEGRATION_NAMES)
end
end end
end end
......
...@@ -1729,22 +1729,42 @@ RSpec.describe Project do ...@@ -1729,22 +1729,42 @@ RSpec.describe Project do
subject { project.disabled_integrations } subject { project.disabled_integrations }
where(:license_feature, :disabled_integrations) do context 'github' do
:github_project_service_integration | %w[github] where(:license_feature, :disabled_integrations) do
end :github_project_service_integration | %w[github]
end
with_them do with_them do
context 'when feature is available' do context 'when feature is available' do
before do before do
stub_licensed_features(license_feature => true) stub_licensed_features(license_feature => true)
end
it { is_expected.not_to include(*disabled_integrations) }
end end
it { is_expected.not_to include(*disabled_integrations) } context 'when feature is unavailable' do
before do
stub_licensed_features(license_feature => false)
end
it { is_expected.to include(*disabled_integrations) }
end
end
end
context 'slack' do
where(:development, :slack_app_enabled, :disabled_integrations) do
true | true | []
true | false | []
false | true | %w[slack_slash_commands]
false | false | %w[gitlab_slack_application]
end end
context 'when feature is unavailable' do with_them do
before do before do
stub_licensed_features(license_feature => false) allow(Rails.env).to receive(:development?).and_return(development)
allow(Gitlab::CurrentSettings).to receive(:slack_app_enabled).and_return(slack_app_enabled)
end end
it { is_expected.to include(*disabled_integrations) } it { is_expected.to include(*disabled_integrations) }
......
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