2016-06-30 15:34:19 +00:00
|
|
|
require 'rails_helper'
|
|
|
|
|
2018-07-05 06:32:05 +00:00
|
|
|
describe 'Issues > User uses quick actions', :js do
|
2018-04-03 10:27:56 +00:00
|
|
|
include Spec::Support::Helpers::Features::NotesHelpers
|
2016-06-30 15:34:19 +00:00
|
|
|
|
2019-03-13 10:45:43 +00:00
|
|
|
context "issuable common quick actions" do
|
|
|
|
let(:new_url_opts) { {} }
|
|
|
|
let(:maintainer) { create(:user) }
|
|
|
|
let(:project) { create(:project, :public) }
|
|
|
|
let!(:label_bug) { create(:label, project: project, title: 'bug') }
|
|
|
|
let!(:label_feature) { create(:label, project: project, title: 'feature') }
|
|
|
|
let!(:milestone) { create(:milestone, project: project, title: 'ASAP') }
|
2016-06-30 15:34:19 +00:00
|
|
|
let(:issuable) { create(:issue, project: project) }
|
2019-03-13 10:45:43 +00:00
|
|
|
let(:source_issuable) { create(:issue, project: project, milestone: milestone, labels: [label_bug, label_feature])}
|
|
|
|
|
|
|
|
it_behaves_like 'assign quick action', :issue
|
|
|
|
it_behaves_like 'unassign quick action', :issue
|
|
|
|
it_behaves_like 'close quick action', :issue
|
|
|
|
it_behaves_like 'reopen quick action', :issue
|
|
|
|
it_behaves_like 'title quick action', :issue
|
|
|
|
it_behaves_like 'todo quick action', :issue
|
|
|
|
it_behaves_like 'done quick action', :issue
|
|
|
|
it_behaves_like 'subscribe quick action', :issue
|
|
|
|
it_behaves_like 'unsubscribe quick action', :issue
|
|
|
|
it_behaves_like 'lock quick action', :issue
|
|
|
|
it_behaves_like 'unlock quick action', :issue
|
|
|
|
it_behaves_like 'milestone quick action', :issue
|
|
|
|
it_behaves_like 'remove_milestone quick action', :issue
|
|
|
|
it_behaves_like 'label quick action', :issue
|
|
|
|
it_behaves_like 'unlabel quick action', :issue
|
|
|
|
it_behaves_like 'relabel quick action', :issue
|
|
|
|
it_behaves_like 'award quick action', :issue
|
|
|
|
it_behaves_like 'estimate quick action', :issue
|
|
|
|
it_behaves_like 'remove_estimate quick action', :issue
|
|
|
|
it_behaves_like 'spend quick action', :issue
|
|
|
|
it_behaves_like 'remove_time_spent quick action', :issue
|
|
|
|
it_behaves_like 'shrug quick action', :issue
|
|
|
|
it_behaves_like 'tableflip quick action', :issue
|
|
|
|
it_behaves_like 'copy_metadata quick action', :issue
|
|
|
|
it_behaves_like 'issuable time tracker', :issue
|
2016-06-30 15:34:19 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
describe 'issue-only commands' do
|
|
|
|
let(:user) { create(:user) }
|
2017-08-02 19:55:11 +00:00
|
|
|
let(:project) { create(:project, :public) }
|
2016-06-30 15:34:19 +00:00
|
|
|
|
|
|
|
before do
|
2018-07-11 14:36:08 +00:00
|
|
|
project.add_maintainer(user)
|
2017-06-21 23:44:10 +00:00
|
|
|
sign_in(user)
|
2017-07-06 16:20:50 +00:00
|
|
|
visit project_issue_path(project, issue)
|
2019-03-13 10:45:43 +00:00
|
|
|
wait_for_all_requests
|
2016-06-30 15:34:19 +00:00
|
|
|
end
|
|
|
|
|
2016-09-08 22:51:35 +00:00
|
|
|
after do
|
2017-05-17 18:25:13 +00:00
|
|
|
wait_for_requests
|
2016-09-08 22:51:35 +00:00
|
|
|
end
|
|
|
|
|
2016-06-30 15:34:19 +00:00
|
|
|
describe 'adding a due date from note' do
|
|
|
|
let(:issue) { create(:issue, project: project) }
|
|
|
|
|
2019-03-13 10:45:43 +00:00
|
|
|
it_behaves_like 'due quick action available and date can be added'
|
2016-09-27 09:29:06 +00:00
|
|
|
|
|
|
|
context 'when the current user cannot update the due date' do
|
|
|
|
let(:guest) { create(:user) }
|
|
|
|
before do
|
2017-12-22 08:18:28 +00:00
|
|
|
project.add_guest(guest)
|
2017-07-07 20:46:20 +00:00
|
|
|
gitlab_sign_out
|
2017-06-21 23:44:10 +00:00
|
|
|
sign_in(guest)
|
2017-07-06 16:20:50 +00:00
|
|
|
visit project_issue_path(project, issue)
|
2016-09-27 09:29:06 +00:00
|
|
|
end
|
|
|
|
|
2019-03-13 10:45:43 +00:00
|
|
|
it_behaves_like 'due quick action not available'
|
2016-06-30 15:34:19 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'removing a due date from note' do
|
|
|
|
let(:issue) { create(:issue, project: project, due_date: Date.new(2016, 8, 28)) }
|
|
|
|
|
2019-03-13 10:45:43 +00:00
|
|
|
it_behaves_like 'remove_due_date action available and due date can be removed'
|
2016-09-27 09:29:06 +00:00
|
|
|
|
|
|
|
context 'when the current user cannot update the due date' do
|
|
|
|
let(:guest) { create(:user) }
|
|
|
|
before do
|
2017-12-22 08:18:28 +00:00
|
|
|
project.add_guest(guest)
|
2017-07-07 20:46:20 +00:00
|
|
|
gitlab_sign_out
|
2017-06-21 23:44:10 +00:00
|
|
|
sign_in(guest)
|
2017-07-06 16:20:50 +00:00
|
|
|
visit project_issue_path(project, issue)
|
2016-09-27 09:29:06 +00:00
|
|
|
end
|
2016-06-30 15:34:19 +00:00
|
|
|
|
2019-03-13 10:45:43 +00:00
|
|
|
it_behaves_like 'remove_due_date action not available'
|
2016-06-30 15:34:19 +00:00
|
|
|
end
|
|
|
|
end
|
2016-09-08 09:18:41 +00:00
|
|
|
|
|
|
|
describe 'toggling the WIP prefix from the title from note' do
|
|
|
|
let(:issue) { create(:issue, project: project) }
|
|
|
|
|
|
|
|
it 'does not recognize the command nor create a note' do
|
2018-04-03 10:27:56 +00:00
|
|
|
add_note("/wip")
|
2016-09-08 09:18:41 +00:00
|
|
|
|
|
|
|
expect(page).not_to have_content '/wip'
|
|
|
|
end
|
|
|
|
end
|
2017-03-30 01:39:06 +00:00
|
|
|
|
|
|
|
describe 'mark issue as duplicate' do
|
|
|
|
let(:issue) { create(:issue, project: project) }
|
|
|
|
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
|
2018-04-03 10:27:56 +00:00
|
|
|
add_note("/duplicate ##{original_issue.to_reference}")
|
2017-03-30 01:39:06 +00:00
|
|
|
|
|
|
|
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}"
|
|
|
|
|
2017-04-05 02:31:48 +00:00
|
|
|
expect(issue.reload).to be_closed
|
2017-03-30 01:39:06 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when the current user cannot update the issue' do
|
|
|
|
let(:guest) { create(:user) }
|
|
|
|
before do
|
2017-12-22 08:18:28 +00:00
|
|
|
project.add_guest(guest)
|
2017-07-18 14:27:00 +00:00
|
|
|
gitlab_sign_out
|
|
|
|
sign_in(guest)
|
|
|
|
visit project_issue_path(project, issue)
|
2017-03-30 01:39:06 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not create a note, and does not mark the issue as a duplicate' do
|
2018-04-03 10:27:56 +00:00
|
|
|
add_note("/duplicate ##{original_issue.to_reference}")
|
2017-03-30 01:39:06 +00:00
|
|
|
|
|
|
|
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}"
|
|
|
|
|
2017-04-05 02:31:48 +00:00
|
|
|
expect(issue.reload).to be_open
|
2017-03-30 01:39:06 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2017-08-09 15:37:06 +00:00
|
|
|
|
2018-06-13 12:42:36 +00:00
|
|
|
describe 'make issue confidential' do
|
|
|
|
let(:issue) { create(:issue, project: project) }
|
|
|
|
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 confidential' do
|
|
|
|
add_note("/confidential")
|
|
|
|
|
|
|
|
expect(page).not_to have_content "/confidential"
|
|
|
|
expect(page).to have_content 'Commands applied'
|
|
|
|
expect(page).to have_content "made the issue confidential"
|
|
|
|
|
|
|
|
expect(issue.reload).to be_confidential
|
|
|
|
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 confidential' do
|
|
|
|
add_note("/confidential")
|
|
|
|
|
|
|
|
expect(page).not_to have_content 'Commands applied'
|
|
|
|
expect(page).not_to have_content "made the issue confidential"
|
|
|
|
|
|
|
|
expect(issue.reload).not_to be_confidential
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-08-09 15:37:06 +00:00
|
|
|
describe 'move the issue to another project' do
|
|
|
|
let(:issue) { create(:issue, project: project) }
|
|
|
|
|
2017-09-15 21:19:24 +00:00
|
|
|
context 'when the project is valid' do
|
2017-08-09 15:37:06 +00:00
|
|
|
let(:target_project) { create(:project, :public) }
|
|
|
|
|
|
|
|
before do
|
2018-07-11 14:36:08 +00:00
|
|
|
target_project.add_maintainer(user)
|
2018-05-03 12:31:32 +00:00
|
|
|
gitlab_sign_out
|
2017-08-09 15:37:06 +00:00
|
|
|
sign_in(user)
|
|
|
|
visit project_issue_path(project, issue)
|
2019-03-13 10:45:43 +00:00
|
|
|
wait_for_requests
|
2017-08-09 15:37:06 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'moves the issue' do
|
2018-04-03 10:27:56 +00:00
|
|
|
add_note("/move #{target_project.full_path}")
|
2017-08-09 15:37:06 +00:00
|
|
|
|
|
|
|
expect(page).to have_content 'Commands applied'
|
|
|
|
expect(issue.reload).to be_closed
|
|
|
|
|
|
|
|
visit project_issue_path(target_project, issue)
|
|
|
|
|
|
|
|
expect(page).to have_content 'Issues 1'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-09-15 21:19:24 +00:00
|
|
|
context 'when the project is valid but the user not authorized' do
|
2018-05-02 12:46:46 +00:00
|
|
|
let(:project_unauthorized) { create(:project, :public) }
|
2017-08-09 15:37:06 +00:00
|
|
|
|
|
|
|
before do
|
2018-05-02 12:46:46 +00:00
|
|
|
gitlab_sign_out
|
2017-08-09 15:37:06 +00:00
|
|
|
sign_in(user)
|
|
|
|
visit project_issue_path(project, issue)
|
2019-03-13 10:45:43 +00:00
|
|
|
wait_for_requests
|
2017-08-09 15:37:06 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not move the issue' do
|
2018-04-03 10:27:56 +00:00
|
|
|
add_note("/move #{project_unauthorized.full_path}")
|
2017-08-09 15:37:06 +00:00
|
|
|
|
2018-06-13 22:09:50 +00:00
|
|
|
wait_for_requests
|
|
|
|
|
|
|
|
expect(page).to have_content 'Commands applied'
|
2017-08-09 15:37:06 +00:00
|
|
|
expect(issue.reload).to be_open
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-09-15 21:19:24 +00:00
|
|
|
context 'when the project is invalid' do
|
2017-08-09 15:37:06 +00:00
|
|
|
before do
|
2018-05-02 12:46:46 +00:00
|
|
|
gitlab_sign_out
|
2017-08-09 15:37:06 +00:00
|
|
|
sign_in(user)
|
|
|
|
visit project_issue_path(project, issue)
|
2019-03-13 10:45:43 +00:00
|
|
|
wait_for_requests
|
2017-08-09 15:37:06 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not move the issue' do
|
2018-04-03 10:27:56 +00:00
|
|
|
add_note("/move not/valid")
|
2017-08-09 15:37:06 +00:00
|
|
|
|
2019-03-04 09:21:47 +00:00
|
|
|
wait_for_requests
|
|
|
|
|
|
|
|
expect(page).to have_content 'Commands applied'
|
2017-08-09 15:37:06 +00:00
|
|
|
expect(issue.reload).to be_open
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-09-15 21:19:24 +00:00
|
|
|
context 'when the user issues multiple commands' do
|
2017-08-09 15:37:06 +00:00
|
|
|
let(:target_project) { create(:project, :public) }
|
|
|
|
let(:milestone) { create(:milestone, title: '1.0', project: project) }
|
|
|
|
let(:target_milestone) { create(:milestone, title: '1.0', project: target_project) }
|
|
|
|
let(:bug) { create(:label, project: project, title: 'bug') }
|
|
|
|
let(:wontfix) { create(:label, project: project, title: 'wontfix') }
|
|
|
|
let(:bug_target) { create(:label, project: target_project, title: 'bug') }
|
|
|
|
let(:wontfix_target) { create(:label, project: target_project, title: 'wontfix') }
|
|
|
|
|
|
|
|
before do
|
2018-07-11 14:36:08 +00:00
|
|
|
target_project.add_maintainer(user)
|
2018-05-03 12:31:32 +00:00
|
|
|
gitlab_sign_out
|
2017-08-09 15:37:06 +00:00
|
|
|
sign_in(user)
|
|
|
|
visit project_issue_path(project, issue)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'applies the commands to both issues and moves the issue' do
|
2018-04-03 10:27:56 +00:00
|
|
|
add_note("/label ~#{bug.title} ~#{wontfix.title}\n\n/milestone %\"#{milestone.title}\"\n\n/move #{target_project.full_path}")
|
2017-08-09 15:37:06 +00:00
|
|
|
|
|
|
|
expect(page).to have_content 'Commands applied'
|
|
|
|
expect(issue.reload).to be_closed
|
|
|
|
|
|
|
|
visit project_issue_path(target_project, issue)
|
|
|
|
|
|
|
|
expect(page).to have_content 'bug'
|
|
|
|
expect(page).to have_content 'wontfix'
|
|
|
|
expect(page).to have_content '1.0'
|
|
|
|
|
|
|
|
visit project_issue_path(project, issue)
|
|
|
|
expect(page).to have_content 'Closed'
|
|
|
|
expect(page).to have_content 'bug'
|
|
|
|
expect(page).to have_content 'wontfix'
|
|
|
|
expect(page).to have_content '1.0'
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'moves the issue and applies the commands to both issues' do
|
2018-04-03 10:27:56 +00:00
|
|
|
add_note("/move #{target_project.full_path}\n\n/label ~#{bug.title} ~#{wontfix.title}\n\n/milestone %\"#{milestone.title}\"")
|
2017-08-09 15:37:06 +00:00
|
|
|
|
|
|
|
expect(page).to have_content 'Commands applied'
|
|
|
|
expect(issue.reload).to be_closed
|
|
|
|
|
|
|
|
visit project_issue_path(target_project, issue)
|
|
|
|
|
|
|
|
expect(page).to have_content 'bug'
|
|
|
|
expect(page).to have_content 'wontfix'
|
|
|
|
expect(page).to have_content '1.0'
|
|
|
|
|
|
|
|
visit project_issue_path(project, issue)
|
|
|
|
expect(page).to have_content 'Closed'
|
|
|
|
expect(page).to have_content 'bug'
|
|
|
|
expect(page).to have_content 'wontfix'
|
|
|
|
expect(page).to have_content '1.0'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2018-10-19 07:16:58 +00:00
|
|
|
|
|
|
|
describe 'create a merge request starting from an issue' do
|
|
|
|
let(:project) { create(:project, :public, :repository) }
|
|
|
|
let(:issue) { create(:issue, project: project) }
|
|
|
|
|
|
|
|
def expect_mr_quickaction(success)
|
|
|
|
expect(page).to have_content 'Commands applied'
|
|
|
|
|
|
|
|
if success
|
|
|
|
expect(page).to have_content 'created merge request'
|
|
|
|
else
|
|
|
|
expect(page).not_to have_content 'created merge request'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it "doesn't create a merge request when the branch name is invalid" do
|
|
|
|
add_note("/create_merge_request invalid branch name")
|
|
|
|
|
|
|
|
wait_for_requests
|
|
|
|
|
|
|
|
expect_mr_quickaction(false)
|
|
|
|
end
|
|
|
|
|
|
|
|
it "doesn't create a merge request when a branch with that name already exists" do
|
|
|
|
add_note("/create_merge_request feature")
|
|
|
|
|
|
|
|
wait_for_requests
|
|
|
|
|
|
|
|
expect_mr_quickaction(false)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'creates a new merge request using issue iid and title as branch name when the branch name is empty' do
|
|
|
|
add_note("/create_merge_request")
|
|
|
|
|
|
|
|
wait_for_requests
|
|
|
|
|
|
|
|
expect_mr_quickaction(true)
|
|
|
|
|
|
|
|
created_mr = project.merge_requests.last
|
|
|
|
expect(created_mr.source_branch).to eq(issue.to_branch_name)
|
|
|
|
|
|
|
|
visit project_merge_request_path(project, created_mr)
|
|
|
|
expect(page).to have_content %{WIP: Resolve "#{issue.title}"}
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'creates a merge request using the given branch name' do
|
|
|
|
branch_name = '1-feature'
|
|
|
|
add_note("/create_merge_request #{branch_name}")
|
|
|
|
|
|
|
|
expect_mr_quickaction(true)
|
|
|
|
|
|
|
|
created_mr = project.merge_requests.last
|
|
|
|
expect(created_mr.source_branch).to eq(branch_name)
|
|
|
|
|
|
|
|
visit project_merge_request_path(project, created_mr)
|
|
|
|
expect(page).to have_content %{WIP: Resolve "#{issue.title}"}
|
|
|
|
end
|
|
|
|
end
|
2016-06-30 15:34:19 +00:00
|
|
|
end
|
|
|
|
end
|