summaryrefslogtreecommitdiff
path: root/spec/services/jira_connect_subscriptions
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-09-19 01:45:44 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-09-19 01:45:44 +0000
commit85dc423f7090da0a52c73eb66faf22ddb20efff9 (patch)
tree9160f299afd8c80c038f08e1545be119f5e3f1e1 /spec/services/jira_connect_subscriptions
parent15c2c8c66dbe422588e5411eee7e68f1fa440bb8 (diff)
downloadgitlab-ce-85dc423f7090da0a52c73eb66faf22ddb20efff9.tar.gz
Add latest changes from gitlab-org/gitlab@13-4-stable-ee
Diffstat (limited to 'spec/services/jira_connect_subscriptions')
-rw-r--r--spec/services/jira_connect_subscriptions/create_service_spec.rb48
1 files changed, 48 insertions, 0 deletions
diff --git a/spec/services/jira_connect_subscriptions/create_service_spec.rb b/spec/services/jira_connect_subscriptions/create_service_spec.rb
new file mode 100644
index 00000000000..77e758cf6fe
--- /dev/null
+++ b/spec/services/jira_connect_subscriptions/create_service_spec.rb
@@ -0,0 +1,48 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe JiraConnectSubscriptions::CreateService do
+ let(:installation) { create(:jira_connect_installation) }
+ let(:current_user) { create(:user) }
+ let(:group) { create(:group) }
+ let(:path) { group.full_path }
+
+ subject { described_class.new(installation, current_user, namespace_path: path).execute }
+
+ before do
+ group.add_maintainer(current_user)
+ end
+
+ shared_examples 'a failed execution' do
+ it 'does not create a subscription' do
+ expect { subject }.not_to change { installation.subscriptions.count }
+ end
+
+ it 'returns an error status' 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)
+ end
+
+ it 'returns success' do
+ expect(subject[:status]).to eq(:success)
+ end
+ end
+
+ context 'when path is invalid' do
+ let(:path) { 'some_invalid_namespace_path' }
+
+ it_behaves_like 'a failed execution'
+ end
+
+ context 'when user does not have access' do
+ subject { described_class.new(installation, create(:user), namespace_path: path).execute }
+
+ it_behaves_like 'a failed execution'
+ end
+end