debian-mirror-gitlab/spec/features/issues/user_uses_slash_commands_spec.rb

269 lines
8.5 KiB
Ruby
Raw Normal View History

2016-09-13 17:45:13 +05:30
require 'rails_helper'
2018-03-17 18:26:18 +05:30
feature 'Issues > User uses quick actions', :js do
2017-09-10 17:25:29 +05:30
include QuickActionsHelpers
2016-09-13 17:45:13 +05:30
2017-09-10 17:25:29 +05:30
it_behaves_like 'issuable record that supports quick actions in its description and notes', :issue do
2016-09-13 17:45:13 +05:30
let(:issuable) { create(:issue, project: project) }
end
describe 'issue-only commands' do
let(:user) { create(:user) }
let(:project) { create(:project, :public) }
before do
2018-03-17 18:26:18 +05:30
project.add_master(user)
2017-09-10 17:25:29 +05:30
sign_in(user)
visit project_issue_path(project, issue)
2016-09-13 17:45:13 +05:30
end
2016-09-29 09:46:39 +05:30
after do
2017-09-10 17:25:29 +05:30
wait_for_requests
end
describe 'time tracking' do
let(:issue) { create(:issue, project: project) }
before do
visit project_issue_path(project, issue)
end
it_behaves_like 'issuable time tracker'
2016-09-29 09:46:39 +05:30
end
2016-09-13 17:45:13 +05:30
describe 'adding a due date from note' do
let(:issue) { create(:issue, project: project) }
2016-11-03 12:29:30 +05:30
context 'when the current user can update the due date' do
it 'does not create a note, and sets the due date accordingly' do
write_note("/due 2016-08-28")
2016-09-13 17:45:13 +05:30
2016-11-03 12:29:30 +05:30
expect(page).not_to have_content '/due 2016-08-28'
2017-08-17 22:00:37 +05:30
expect(page).to have_content 'Commands applied'
2016-09-13 17:45:13 +05:30
2016-11-03 12:29:30 +05:30
issue.reload
2016-09-13 17:45:13 +05:30
2016-11-03 12:29:30 +05:30
expect(issue.due_date).to eq Date.new(2016, 8, 28)
end
end
context 'when the current user cannot update the due date' do
let(:guest) { create(:user) }
before do
2018-03-17 18:26:18 +05:30
project.add_guest(guest)
2017-09-10 17:25:29 +05:30
gitlab_sign_out
sign_in(guest)
visit project_issue_path(project, issue)
2016-11-03 12:29:30 +05:30
end
it 'does not create a note, and sets the due date accordingly' do
write_note("/due 2016-08-28")
expect(page).to have_content '/due 2016-08-28'
2017-08-17 22:00:37 +05:30
expect(page).not_to have_content 'Commands applied'
2016-11-03 12:29:30 +05:30
issue.reload
expect(issue.due_date).to be_nil
end
2016-09-13 17:45:13 +05:30
end
end
describe 'removing a due date from note' do
let(:issue) { create(:issue, project: project, due_date: Date.new(2016, 8, 28)) }
2016-11-03 12:29:30 +05:30
context 'when the current user can update the due date' do
it 'does not create a note, and removes the due date accordingly' do
expect(issue.due_date).to eq Date.new(2016, 8, 28)
write_note("/remove_due_date")
expect(page).not_to have_content '/remove_due_date'
2017-08-17 22:00:37 +05:30
expect(page).to have_content 'Commands applied'
2016-11-03 12:29:30 +05:30
issue.reload
2016-09-13 17:45:13 +05:30
2016-11-03 12:29:30 +05:30
expect(issue.due_date).to be_nil
end
end
context 'when the current user cannot update the due date' do
let(:guest) { create(:user) }
before do
2018-03-17 18:26:18 +05:30
project.add_guest(guest)
2017-09-10 17:25:29 +05:30
gitlab_sign_out
sign_in(guest)
visit project_issue_path(project, issue)
2016-11-03 12:29:30 +05:30
end
it 'does not create a note, and sets the due date accordingly' do
write_note("/remove_due_date")
expect(page).to have_content '/remove_due_date'
2017-08-17 22:00:37 +05:30
expect(page).not_to have_content 'Commands applied'
2016-11-03 12:29:30 +05:30
issue.reload
2016-09-13 17:45:13 +05:30
2016-11-03 12:29:30 +05:30
expect(issue.due_date).to eq Date.new(2016, 8, 28)
end
end
end
2017-09-10 17:25:29 +05:30
describe 'toggling the WIP prefix from the title from note' do
2017-08-17 22:00:37 +05:30
let(:issue) { create(:issue, project: project) }
2017-09-10 17:25:29 +05:30
it 'does not recognize the command nor create a note' do
write_note("/wip")
2017-08-17 22:00:37 +05:30
2017-09-10 17:25:29 +05:30
expect(page).not_to have_content '/wip'
2017-08-17 22:00:37 +05:30
end
end
2017-09-10 17:25:29 +05:30
describe 'mark issue as duplicate' do
2017-08-17 22:00:37 +05:30
let(:issue) { create(:issue, project: project) }
2017-09-10 17:25:29 +05:30
let(:original_issue) { create(:issue, project: project) }
2017-08-17 22:00:37 +05:30
2017-09-10 17:25:29 +05:30
context 'when the current user can update issues' do
it 'does not create a note, and marks the issue as a duplicate' do
write_note("/duplicate ##{original_issue.to_reference}")
2017-08-17 22:00:37 +05:30
2017-09-10 17:25:29 +05:30
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-08-17 22:00:37 +05:30
2017-09-10 17:25:29 +05:30
expect(issue.reload).to be_closed
end
2017-08-17 22:00:37 +05:30
end
2017-09-10 17:25:29 +05:30
context 'when the current user cannot update the issue' do
let(:guest) { create(:user) }
2017-08-17 22:00:37 +05:30
before do
2018-03-17 18:26:18 +05:30
project.add_guest(guest)
2017-09-10 17:25:29 +05:30
gitlab_sign_out
sign_in(guest)
visit project_issue_path(project, issue)
2017-08-17 22:00:37 +05:30
end
2017-09-10 17:25:29 +05:30
it 'does not create a note, and does not mark the issue as a duplicate' do
write_note("/duplicate ##{original_issue.to_reference}")
2016-09-13 17:45:13 +05:30
2017-09-10 17:25:29 +05:30
expect(page).to have_content "/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}"
2016-09-13 17:45:13 +05:30
2017-09-10 17:25:29 +05:30
expect(issue.reload).to be_open
end
2016-09-13 17:45:13 +05:30
end
end
2018-03-17 18:26:18 +05:30
describe 'move the issue to another project' do
let(:issue) { create(:issue, project: project) }
context 'when the project is valid' do
let(:target_project) { create(:project, :public) }
before do
target_project.add_master(user)
sign_in(user)
visit project_issue_path(project, issue)
end
it 'moves the issue' do
write_note("/move #{target_project.full_path}")
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
context 'when the project is valid but the user not authorized' do
let(:project_unauthorized) {create(:project, :public)}
before do
sign_in(user)
visit project_issue_path(project, issue)
end
it 'does not move the issue' do
write_note("/move #{project_unauthorized.full_path}")
expect(page).not_to have_content 'Commands applied'
expect(issue.reload).to be_open
end
end
context 'when the project is invalid' do
before do
sign_in(user)
visit project_issue_path(project, issue)
end
it 'does not move the issue' do
write_note("/move not/valid")
expect(page).not_to have_content 'Commands applied'
expect(issue.reload).to be_open
end
end
context 'when the user issues multiple commands' do
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
target_project.add_master(user)
sign_in(user)
visit project_issue_path(project, issue)
end
it 'applies the commands to both issues and moves the issue' do
write_note("/label ~#{bug.title} ~#{wontfix.title}\n\n/milestone %\"#{milestone.title}\"\n\n/move #{target_project.full_path}")
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
write_note("/move #{target_project.full_path}\n\n/label ~#{bug.title} ~#{wontfix.title}\n\n/milestone %\"#{milestone.title}\"")
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
2016-09-13 17:45:13 +05:30
end
end