2019-07-25 01:24:42 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2019-08-29 03:56:52 -04:00
|
|
|
require 'spec_helper'
|
2016-03-16 10:11:07 -04:00
|
|
|
|
2020-06-16 14:09:01 -04:00
|
|
|
RSpec.describe 'issue move to another project' do
|
2016-03-16 10:11:07 -04:00
|
|
|
let(:user) { create(:user) }
|
2017-07-26 17:49:06 -04:00
|
|
|
let(:old_project) { create(:project, :repository) }
|
2016-03-16 10:11:07 -04:00
|
|
|
let(:text) { 'Some issue description' }
|
|
|
|
|
|
|
|
let(:issue) do
|
|
|
|
create(:issue, description: text, project: old_project, author: user)
|
|
|
|
end
|
|
|
|
|
2018-07-05 02:32:05 -04:00
|
|
|
before do
|
|
|
|
sign_in(user)
|
|
|
|
end
|
2016-03-16 10:11:07 -04:00
|
|
|
|
|
|
|
context 'user does not have permission to move issue' do
|
2018-07-05 02:32:05 -04:00
|
|
|
before do
|
2017-12-22 03:18:28 -05:00
|
|
|
old_project.add_guest(user)
|
2016-03-16 10:11:07 -04:00
|
|
|
|
2017-08-14 03:26:19 -04:00
|
|
|
visit issue_path(issue)
|
2016-03-16 10:11:07 -04:00
|
|
|
end
|
|
|
|
|
2018-07-05 02:32:05 -04:00
|
|
|
it 'moving issue to another project not allowed' do
|
2017-08-14 03:26:19 -04:00
|
|
|
expect(page).to have_no_selector('.js-sidebar-move-issue-block')
|
2016-03-16 10:11:07 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'user has permission to move issue' do
|
|
|
|
let!(:mr) { create(:merge_request, source_project: old_project) }
|
2017-08-02 15:55:11 -04:00
|
|
|
let(:new_project) { create(:project) }
|
|
|
|
let(:new_project_search) { create(:project) }
|
2016-11-23 01:55:23 -05:00
|
|
|
let(:text) { "Text with #{mr.to_reference}" }
|
2020-01-29 07:09:08 -05:00
|
|
|
let(:cross_reference) { old_project.to_reference_base(new_project) }
|
2016-03-16 10:11:07 -04:00
|
|
|
|
2018-07-05 02:32:05 -04:00
|
|
|
before do
|
2017-12-22 03:18:28 -05:00
|
|
|
old_project.add_reporter(user)
|
|
|
|
new_project.add_reporter(user)
|
2016-03-16 10:11:07 -04:00
|
|
|
|
2017-08-14 03:26:19 -04:00
|
|
|
visit issue_path(issue)
|
2016-03-16 10:11:07 -04:00
|
|
|
end
|
|
|
|
|
2018-07-05 02:32:05 -04:00
|
|
|
it 'moving issue to another project', :js do
|
2017-09-19 13:51:16 -04:00
|
|
|
find('.js-move-issue').click
|
2017-08-14 03:26:19 -04:00
|
|
|
wait_for_requests
|
|
|
|
all('.js-move-issue-dropdown-item')[0].click
|
|
|
|
find('.js-move-issue-confirmation-button').click
|
2016-03-16 10:11:07 -04:00
|
|
|
|
2016-11-23 01:55:23 -05:00
|
|
|
expect(page).to have_content("Text with #{cross_reference}#{mr.to_reference}")
|
|
|
|
expect(page).to have_content("moved from #{cross_reference}#{issue.to_reference}")
|
2016-04-01 08:44:22 -04:00
|
|
|
expect(page).to have_content(issue.title)
|
2017-07-04 07:51:28 -04:00
|
|
|
expect(page.current_path).to include project_path(new_project)
|
2016-03-16 10:11:07 -04:00
|
|
|
end
|
|
|
|
|
2018-07-05 02:32:05 -04:00
|
|
|
it 'searching project dropdown', :js do
|
2017-12-22 03:18:28 -05:00
|
|
|
new_project_search.add_reporter(user)
|
2016-06-15 06:34:11 -04:00
|
|
|
|
2017-09-19 13:51:16 -04:00
|
|
|
find('.js-move-issue').click
|
2017-08-14 03:26:19 -04:00
|
|
|
wait_for_requests
|
2016-06-15 06:34:11 -04:00
|
|
|
|
2017-08-14 03:26:19 -04:00
|
|
|
page.within '.js-sidebar-move-issue-block' do
|
|
|
|
fill_in('sidebar-move-issue-dropdown-search', with: new_project_search.name)
|
2016-06-15 06:34:11 -04:00
|
|
|
|
|
|
|
expect(page).to have_content(new_project_search.name)
|
|
|
|
expect(page).not_to have_content(new_project.name)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-10-03 04:35:01 -04:00
|
|
|
context 'user does not have permission to move the issue to a project', :js do
|
2017-08-02 15:55:11 -04:00
|
|
|
let!(:private_project) { create(:project, :private) }
|
|
|
|
let(:another_project) { create(:project) }
|
2019-12-17 13:07:48 -05:00
|
|
|
|
2018-07-05 02:32:05 -04:00
|
|
|
before do
|
|
|
|
another_project.add_guest(user)
|
|
|
|
end
|
2016-03-16 10:11:07 -04:00
|
|
|
|
2018-07-05 02:32:05 -04:00
|
|
|
it 'browsing projects in projects select' do
|
2017-09-19 13:51:16 -04:00
|
|
|
find('.js-move-issue').click
|
2017-08-14 03:26:19 -04:00
|
|
|
wait_for_requests
|
2016-05-16 12:17:40 -04:00
|
|
|
|
2017-08-14 03:26:19 -04:00
|
|
|
page.within '.js-sidebar-move-issue-block' do
|
2018-03-05 09:15:26 -05:00
|
|
|
expect(page).to have_content new_project.full_name
|
2016-05-16 12:17:40 -04:00
|
|
|
end
|
2016-03-16 10:11:07 -04:00
|
|
|
end
|
|
|
|
end
|
2016-03-17 06:11:22 -04:00
|
|
|
|
|
|
|
context 'issue has been already moved' do
|
|
|
|
let(:new_issue) { create(:issue, project: new_project) }
|
|
|
|
let(:issue) do
|
|
|
|
create(:issue, project: old_project, author: user, moved_to: new_issue)
|
|
|
|
end
|
|
|
|
|
2018-07-05 02:32:05 -04:00
|
|
|
it 'user wants to move issue that has already been moved' do
|
2016-05-16 12:17:40 -04:00
|
|
|
expect(page).to have_no_selector('#move_to_project_id')
|
2016-03-17 06:11:22 -04:00
|
|
|
end
|
|
|
|
end
|
2016-03-16 10:11:07 -04:00
|
|
|
end
|
|
|
|
|
2020-07-15 17:09:26 -04:00
|
|
|
context 'service desk issue moved to a project with service desk disabled', :js do
|
|
|
|
let(:project_title) { 'service desk disabled project' }
|
|
|
|
let(:warning_selector) { '.js-alert-moved-from-service-desk-warning' }
|
|
|
|
let(:namespace) { create(:namespace) }
|
|
|
|
let(:regular_project) { create(:project, title: project_title, service_desk_enabled: false) }
|
|
|
|
let(:service_desk_project) { build(:project, :private, namespace: namespace, service_desk_enabled: true) }
|
|
|
|
let(:service_desk_issue) { create(:issue, project: service_desk_project, author: ::User.support_bot) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
allow(Gitlab).to receive(:com?).and_return(true)
|
|
|
|
allow(Gitlab::IncomingEmail).to receive(:enabled?).and_return(true)
|
|
|
|
allow(Gitlab::IncomingEmail).to receive(:supports_wildcard?).and_return(true)
|
|
|
|
|
|
|
|
regular_project.add_reporter(user)
|
|
|
|
service_desk_project.add_reporter(user)
|
|
|
|
|
|
|
|
visit issue_path(service_desk_issue)
|
|
|
|
|
|
|
|
find('.js-move-issue').click
|
|
|
|
wait_for_requests
|
|
|
|
find('.js-move-issue-dropdown-item', text: project_title).click
|
|
|
|
find('.js-move-issue-confirmation-button').click
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows an alert after being moved' do
|
|
|
|
expect(page).to have_content('This project does not have Service Desk enabled')
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not show an alert after being dismissed' do
|
|
|
|
find("#{warning_selector} .js-close").click
|
|
|
|
|
|
|
|
expect(page).to have_no_selector(warning_selector)
|
|
|
|
|
|
|
|
page.refresh
|
|
|
|
|
|
|
|
expect(page).to have_no_selector(warning_selector)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-03-16 10:11:07 -04:00
|
|
|
def issue_path(issue)
|
2017-07-06 12:20:50 -04:00
|
|
|
project_issue_path(issue.project, issue)
|
2016-03-16 10:11:07 -04:00
|
|
|
end
|
|
|
|
end
|