Commit 5f9eba6c authored by Felipe Artur's avatar Felipe Artur

Check if incoming emails and email key are available for service desk

parent 0997a5ae
...@@ -36,8 +36,9 @@ module EE ...@@ -36,8 +36,9 @@ module EE
private private
def service_desk_available? def service_desk_available?
@service_desk_available ||= return @service_desk_available if defined?(@service_desk_available)
EE::Gitlab::ServiceDesk.enabled? && service_desk_enabled?
@service_desk_available = EE::Gitlab::ServiceDesk.enabled? && service_desk_enabled?
end end
end end
end end
---
title: Check if incoming emails and email key are available for service desk
merge_request:
author:
...@@ -2,7 +2,10 @@ module EE ...@@ -2,7 +2,10 @@ module EE
module Gitlab module Gitlab
module ServiceDesk module ServiceDesk
def self.enabled? def self.enabled?
::License.current && ::License.current.add_on?('GitLab_ServiceDesk') ::License.current &&
::License.current.add_on?('GitLab_ServiceDesk') &&
::Gitlab::IncomingEmail.enabled? &&
::Gitlab::IncomingEmail.supports_wildcard?
end end
end end
end end
......
...@@ -7,6 +7,8 @@ describe Projects::ServiceDeskController do ...@@ -7,6 +7,8 @@ describe Projects::ServiceDeskController do
before do before do
allow_any_instance_of(License).to receive(:add_on?).and_call_original allow_any_instance_of(License).to receive(:add_on?).and_call_original
allow_any_instance_of(License).to receive(:add_on?).with('GitLab_ServiceDesk') { true } allow_any_instance_of(License).to receive(:add_on?).with('GitLab_ServiceDesk') { true }
allow(Gitlab::IncomingEmail).to receive(:enabled?) { true }
allow(Gitlab::IncomingEmail).to receive(:supports_wildcard?) { true }
project.update(service_desk_enabled: true) project.update(service_desk_enabled: true)
project.add_master(user) project.add_master(user)
sign_in(user) sign_in(user)
......
...@@ -11,6 +11,8 @@ describe 'Service Desk Setting', js: true, feature: true do ...@@ -11,6 +11,8 @@ describe 'Service Desk Setting', js: true, feature: true do
login_as(user) login_as(user)
allow_any_instance_of(License).to receive(:add_on?).and_call_original allow_any_instance_of(License).to receive(:add_on?).and_call_original
allow_any_instance_of(License).to receive(:add_on?).with('GitLab_ServiceDesk') { true } allow_any_instance_of(License).to receive(:add_on?).with('GitLab_ServiceDesk') { true }
allow(::Gitlab::IncomingEmail).to receive(:enabled?) { true }
allow(::Gitlab::IncomingEmail).to receive(:supports_wildcard?) { true }
visit edit_namespace_project_path(project.namespace, project) visit edit_namespace_project_path(project.namespace, project)
end end
......
require 'spec_helper'
describe EE::Gitlab::ServiceDesk, lib: true do
before do
allow_any_instance_of(License).to receive(:add_on?).and_call_original
allow_any_instance_of(License).to receive(:add_on?).with('GitLab_ServiceDesk') { true }
allow(::Gitlab::IncomingEmail).to receive(:enabled?) { true }
allow(::Gitlab::IncomingEmail).to receive(:supports_wildcard?) { true }
end
subject { described_class.enabled? }
it { is_expected.to be_truthy }
context 'when license does not support service desk' do
before do
allow_any_instance_of(License).to receive(:add_on?).with('GitLab_ServiceDesk') { false }
end
it { is_expected.to be_falsy }
end
context 'when incoming emails are disabled' do
before do
allow(::Gitlab::IncomingEmail).to receive(:enabled?) { false }
end
it { is_expected.to be_falsy }
end
context 'when email key is not supported' do
before do
allow(::Gitlab::IncomingEmail).to receive(:supports_wildcard?) { false }
end
it { is_expected.to be_falsy }
end
end
...@@ -21,6 +21,8 @@ describe Gitlab::Email::Handler::EE::ServiceDeskHandler do ...@@ -21,6 +21,8 @@ describe Gitlab::Email::Handler::EE::ServiceDeskHandler do
allow_any_instance_of(License).to receive(:add_on?).and_call_original allow_any_instance_of(License).to receive(:add_on?).and_call_original
allow_any_instance_of(License).to receive(:add_on?).with('GitLab_ServiceDesk') { true } allow_any_instance_of(License).to receive(:add_on?).with('GitLab_ServiceDesk') { true }
allow(::Gitlab::IncomingEmail).to receive(:enabled?) { true }
allow(::Gitlab::IncomingEmail).to receive(:supports_wildcard?) { true }
end end
it 'sends thank you the email and creates issue' do it 'sends thank you the email and creates issue' do
......
...@@ -9,6 +9,8 @@ describe EE::NotificationService do ...@@ -9,6 +9,8 @@ describe EE::NotificationService do
allow_any_instance_of(License).to receive(:add_on?).and_call_original allow_any_instance_of(License).to receive(:add_on?).and_call_original
allow_any_instance_of(License).to receive(:add_on?).with('GitLab_ServiceDesk') { true } allow_any_instance_of(License).to receive(:add_on?).with('GitLab_ServiceDesk') { true }
allow(::Gitlab::IncomingEmail).to receive(:enabled?) { true }
allow(::Gitlab::IncomingEmail).to receive(:supports_wildcard?) { true }
end end
def should_email! def should_email!
......
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