summaryrefslogtreecommitdiff
path: root/spec/services/quick_actions
diff options
context:
space:
mode:
authorRyan Scott <ryan@ryan-scott.me>2017-03-30 10:39:06 +0900
committerSean McGivern <sean@gitlab.com>2017-07-20 15:33:24 +0100
commit01c9488f4a559063eba77074ba2d369de87b8018 (patch)
treeffd18d3ebd174cf47ab9eb71cbacd940d4cf2831 /spec/services/quick_actions
parentb6555693a8e445405c5746b7c76c9f603395bba2 (diff)
downloadgitlab-ce-01c9488f4a559063eba77074ba2d369de87b8018.tar.gz
Added slash command to close an issue as a duplicate. Closes #26372
Diffstat (limited to 'spec/services/quick_actions')
-rw-r--r--spec/services/quick_actions/interpret_service_spec.rb36
1 files changed, 36 insertions, 0 deletions
diff --git a/spec/services/quick_actions/interpret_service_spec.rb b/spec/services/quick_actions/interpret_service_spec.rb
index a2db3f68ff7..3e4aa66756c 100644
--- a/spec/services/quick_actions/interpret_service_spec.rb
+++ b/spec/services/quick_actions/interpret_service_spec.rb
@@ -261,6 +261,17 @@ describe QuickActions::InterpretService, services: true do
end
end
+ shared_examples 'duplicate command' do
+ let(:issue_duplicate) { create(:issue, project: project) }
+
+ it 'fetches issue and populates original_issue_id if content contains /duplicate issue_reference' do
+ issue_duplicate # populate the issue
+ _, updates = service.execute(content, issuable)
+
+ expect(updates).to eq(original_issue_id: issue_duplicate.id)
+ end
+ end
+
it_behaves_like 'reopen command' do
let(:content) { '/reopen' }
let(:issuable) { issue }
@@ -644,6 +655,26 @@ describe QuickActions::InterpretService, services: true do
let(:issuable) { issue }
end
+ it_behaves_like 'duplicate command' do
+ let(:content) { "/duplicate #{issue_duplicate.to_reference}" }
+ let(:issuable) { issue }
+ end
+
+ it_behaves_like 'empty command' do
+ let(:content) { '/duplicate #{issue.to_reference}' }
+ let(:issuable) { issue }
+ end
+
+ it_behaves_like 'empty command' do
+ let(:content) { '/duplicate' }
+ let(:issuable) { issue }
+ end
+
+ it_behaves_like 'empty command' do
+ let(:content) { '/duplicate imaginary#1234' }
+ let(:issuable) { issue }
+ end
+
context 'when current_user cannot :admin_issue' do
let(:visitor) { create(:user) }
let(:issue) { create(:issue, project: project, author: visitor) }
@@ -693,6 +724,11 @@ describe QuickActions::InterpretService, services: true do
let(:content) { '/remove_due_date' }
let(:issuable) { issue }
end
+
+ it_behaves_like 'empty command' do
+ let(:content) { '/duplicate #{issue.to_reference}' }
+ let(:issuable) { issue }
+ end
end
context '/award command' do