diff options
author | Alexandru Croitor <acroitor@gitlab.com> | 2019-04-03 13:26:32 +0300 |
---|---|---|
committer | Alexandru Croitor <acroitor@gitlab.com> | 2019-04-05 23:07:02 +0300 |
commit | 5b64beca82b17d37e5ab2206175c06242ae5ac27 (patch) | |
tree | 9f06c8064d122eaed39a0135755b20e7bd6b3e95 /spec/support/shared_examples/quick_actions | |
parent | e3fedd68c253dace20a380bc2a4193aa5bf243ab (diff) |
Extract duplicate quick action spec to a shared example
Diffstat (limited to 'spec/support/shared_examples/quick_actions')
-rw-r--r-- | spec/support/shared_examples/quick_actions/issue/duplicate_quick_action_shared_examples.rb | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/spec/support/shared_examples/quick_actions/issue/duplicate_quick_action_shared_examples.rb b/spec/support/shared_examples/quick_actions/issue/duplicate_quick_action_shared_examples.rb index 24576fe0021..633c7135fbc 100644 --- a/spec/support/shared_examples/quick_actions/issue/duplicate_quick_action_shared_examples.rb +++ b/spec/support/shared_examples/quick_actions/issue/duplicate_quick_action_shared_examples.rb @@ -1,4 +1,38 @@ # frozen_string_literal: true shared_examples 'duplicate quick action' do + context 'mark issue as duplicate' do + let(:original_issue) { create(:issue, project: project) } + + context 'when the current user can update issues' do + it 'does not create a note, and marks the issue as a duplicate' do + add_note("/duplicate ##{original_issue.to_reference}") + + expect(page).not_to have_content "/duplicate #{original_issue.to_reference}" + expect(page).to have_content 'Commands applied' + expect(page).to have_content "marked this issue as a duplicate of #{original_issue.to_reference}" + + expect(issue.reload).to be_closed + end + end + + context 'when the current user cannot update the issue' do + let(:guest) { create(:user) } + before do + project.add_guest(guest) + gitlab_sign_out + sign_in(guest) + visit project_issue_path(project, issue) + end + + it 'does not create a note, and does not mark the issue as a duplicate' do + add_note("/duplicate ##{original_issue.to_reference}") + + expect(page).not_to have_content 'Commands applied' + expect(page).not_to have_content "marked this issue as a duplicate of #{original_issue.to_reference}" + + expect(issue.reload).to be_open + end + end + end end |