summaryrefslogtreecommitdiff
path: root/spec/services
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-08-30 19:44:55 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2021-08-30 19:44:55 +0000
commitf526ce392a317feb5a125bb16adb2629a487ce70 (patch)
tree8ab2b3458181a6cce84b401ce7dc9326fc0f5384 /spec/services
parentf19a0fa10a0024fab5ef3c556612944f2a62c298 (diff)
downloadgitlab-ce-f526ce392a317feb5a125bb16adb2629a487ce70.tar.gz
Add latest changes from gitlab-org/security/gitlab@14-2-stable-ee
Diffstat (limited to 'spec/services')
-rw-r--r--spec/services/jira_connect_subscriptions/create_service_spec.rb28
1 files changed, 27 insertions, 1 deletions
diff --git a/spec/services/jira_connect_subscriptions/create_service_spec.rb b/spec/services/jira_connect_subscriptions/create_service_spec.rb
index 5f467a07a78..cde4753cde7 100644
--- a/spec/services/jira_connect_subscriptions/create_service_spec.rb
+++ b/spec/services/jira_connect_subscriptions/create_service_spec.rb
@@ -7,8 +7,10 @@ RSpec.describe JiraConnectSubscriptions::CreateService do
let(:current_user) { create(:user) }
let(:group) { create(:group) }
let(:path) { group.full_path }
+ let(:params) { { namespace_path: path, jira_user: jira_user } }
+ let(:jira_user) { double(:JiraUser, site_admin?: true) }
- subject { described_class.new(installation, current_user, namespace_path: path).execute }
+ subject { described_class.new(installation, current_user, params).execute }
before do
group.add_maintainer(current_user)
@@ -24,6 +26,30 @@ RSpec.describe JiraConnectSubscriptions::CreateService do
end
end
+ context 'remote user does not have access' do
+ let(:jira_user) { double(site_admin?: false) }
+
+ it 'does not create a subscription' do
+ expect { subject }.not_to change { installation.subscriptions.count }
+ end
+
+ it 'returns error' do
+ expect(subject[:status]).to eq(:error)
+ end
+ end
+
+ context 'remote user cannot be retrieved' do
+ let(:jira_user) { nil }
+
+ it 'does not create a subscription' do
+ expect { subject }.not_to change { installation.subscriptions.count }
+ end
+
+ it 'returns error' do
+ expect(subject[:status]).to eq(:error)
+ end
+ end
+
context 'when user does have access' do
it 'creates a subscription' do
expect { subject }.to change { installation.subscriptions.count }.from(0).to(1)