summaryrefslogtreecommitdiff
path: root/spec/services/issues
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-12-12 18:07:34 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2019-12-12 18:07:34 +0000
commit90859e80ca23b8709d56b60d2066b569053e7e02 (patch)
tree15d9ac5c194220fab358c42325645fdf2c6ead13 /spec/services/issues
parent7530cf5ad8dd86fbe19e129b6bb31b23849ed757 (diff)
downloadgitlab-ce-90859e80ca23b8709d56b60d2066b569053e7e02.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/services/issues')
-rw-r--r--spec/services/issues/zoom_link_service_spec.rb69
1 files changed, 55 insertions, 14 deletions
diff --git a/spec/services/issues/zoom_link_service_spec.rb b/spec/services/issues/zoom_link_service_spec.rb
index ecca9467965..f34d2a18552 100644
--- a/spec/services/issues/zoom_link_service_spec.rb
+++ b/spec/services/issues/zoom_link_service_spec.rb
@@ -27,12 +27,18 @@ describe Issues::ZoomLinkService do
end
end
- shared_context 'insufficient permissions' do
+ shared_context 'insufficient issue update permissions' do
before do
project.add_guest(user)
end
end
+ shared_context 'insufficient issue create permissions' do
+ before do
+ expect(service).to receive(:can?).with(user, :create_issue, project).and_return(false)
+ end
+ end
+
describe '#add_link' do
shared_examples 'can add meeting' do
it 'appends the new meeting to zoom_meetings' do
@@ -69,16 +75,38 @@ describe Issues::ZoomLinkService do
subject(:result) { service.add_link(zoom_link) }
context 'without existing Zoom meeting' do
- include_examples 'can add meeting'
+ context 'when updating an issue' do
+ before do
+ allow(issue).to receive(:persisted?).and_return(true)
+ end
- context 'with invalid Zoom url' do
- let(:zoom_link) { 'https://not-zoom.link' }
+ include_examples 'can add meeting'
- include_examples 'cannot add meeting'
+ context 'with insufficient issue update permissions' do
+ include_context 'insufficient issue update permissions'
+ include_examples 'cannot add meeting'
+ end
end
- context 'with insufficient permissions' do
- include_context 'insufficient permissions'
+ context 'when creating an issue' do
+ before do
+ allow(issue).to receive(:persisted?).and_return(false)
+ end
+
+ it 'creates a new zoom meeting' do
+ expect(result).to be_success
+ expect(result.payload[:zoom_meetings][0].url).to eq(zoom_link)
+ end
+
+ context 'with insufficient issue create permissions' do
+ include_context 'insufficient issue create permissions'
+ include_examples 'cannot add meeting'
+ end
+ end
+
+ context 'with invalid Zoom url' do
+ let(:zoom_link) { 'https://not-zoom.link' }
+
include_examples 'cannot add meeting'
end
end
@@ -92,6 +120,7 @@ describe Issues::ZoomLinkService do
include_context '"added" Zoom meeting'
before do
allow(service).to receive(:can_add_link?).and_return(true)
+ allow(issue).to receive(:persisted?).and_return(true)
end
include_examples 'cannot add meeting'
@@ -104,8 +133,8 @@ describe Issues::ZoomLinkService do
context 'without "added" zoom meeting' do
it { is_expected.to eq(true) }
- context 'with insufficient permissions' do
- include_context 'insufficient permissions'
+ context 'with insufficient issue update permissions' do
+ include_context 'insufficient issue update permissions'
it { is_expected.to eq(false) }
end
@@ -156,12 +185,24 @@ describe Issues::ZoomLinkService do
context 'with Zoom meeting' do
include_context '"added" Zoom meeting'
- context 'removes the link' do
+ context 'with existing issue' do
+ before do
+ allow(issue).to receive(:persisted?).and_return(true)
+ end
+
include_examples 'can remove meeting'
end
- context 'with insufficient permissions' do
- include_context 'insufficient permissions'
+ context 'without existing issue' do
+ before do
+ allow(issue).to receive(:persisted?).and_return(false)
+ end
+
+ include_examples 'cannot remove meeting'
+ end
+
+ context 'with insufficient issue update permissions' do
+ include_context 'insufficient issue update permissions'
include_examples 'cannot remove meeting'
end
end
@@ -193,8 +234,8 @@ describe Issues::ZoomLinkService do
it { is_expected.to eq(true) }
end
- context 'with insufficient permissions' do
- include_context 'insufficient permissions'
+ context 'with insufficient issue update permissions' do
+ include_context 'insufficient issue update permissions'
it { is_expected.to eq(false) }
end
end