2016-09-13 17:45:13 +05:30
|
|
|
require 'rails_helper'
|
|
|
|
|
|
|
|
feature 'Issues > User uses slash commands', feature: true, js: true do
|
2016-09-29 09:46:39 +05:30
|
|
|
include SlashCommandsHelpers
|
2016-09-13 17:45:13 +05:30
|
|
|
include WaitForAjax
|
|
|
|
|
|
|
|
it_behaves_like 'issuable record that supports slash commands in its description and notes', :issue do
|
|
|
|
let(:issuable) { create(:issue, project: project) }
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'issue-only commands' do
|
|
|
|
let(:user) { create(:user) }
|
|
|
|
let(:project) { create(:project, :public) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
project.team << [user, :master]
|
|
|
|
login_with(user)
|
|
|
|
visit namespace_project_issue_path(project.namespace, project, issue)
|
|
|
|
end
|
|
|
|
|
2016-09-29 09:46:39 +05:30
|
|
|
after do
|
|
|
|
wait_for_ajax
|
|
|
|
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'
|
|
|
|
expect(page).to have_content 'Your commands have been executed!'
|
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
|
|
|
|
project.team << [guest, :guest]
|
|
|
|
logout
|
|
|
|
login_with(guest)
|
|
|
|
visit namespace_project_issue_path(project.namespace, project, issue)
|
|
|
|
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'
|
|
|
|
expect(page).not_to have_content 'Your commands have been executed!'
|
|
|
|
|
|
|
|
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'
|
|
|
|
expect(page).to have_content 'Your commands have been executed!'
|
|
|
|
|
|
|
|
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
|
|
|
|
project.team << [guest, :guest]
|
|
|
|
logout
|
|
|
|
login_with(guest)
|
|
|
|
visit namespace_project_issue_path(project.namespace, project, issue)
|
|
|
|
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'
|
|
|
|
expect(page).not_to have_content 'Your commands have been executed!'
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
describe 'toggling the WIP prefix from the title from note' do
|
|
|
|
let(:issue) { create(:issue, project: project) }
|
2016-09-13 17:45:13 +05:30
|
|
|
|
2016-11-03 12:29:30 +05:30
|
|
|
it 'does not recognize the command nor create a note' do
|
|
|
|
write_note("/wip")
|
2016-09-13 17:45:13 +05:30
|
|
|
|
2016-11-03 12:29:30 +05:30
|
|
|
expect(page).not_to have_content '/wip'
|
2016-09-13 17:45:13 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|