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

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

142 lines
4.4 KiB
Ruby
Raw Normal View History

2019-10-12 21:52:04 +05:30
# frozen_string_literal: true
2019-12-04 20:38:33 +05:30
require 'spec_helper'
2016-06-02 11:05:42 +05:30
2023-03-04 22:38:38 +05:30
RSpec.describe 'issue move to another project', feature_category: :team_planning do
2016-06-02 11:05:42 +05:30
let(:user) { create(:user) }
2017-09-10 17:25:29 +05:30
let(:old_project) { create(:project, :repository) }
2016-06-02 11:05:42 +05:30
let(:text) { 'Some issue description' }
let(:issue) do
create(:issue, description: text, project: old_project, author: user)
end
2018-11-08 19:23:39 +05:30
before do
sign_in(user)
end
2016-06-02 11:05:42 +05:30
context 'user does not have permission to move issue' do
2018-11-08 19:23:39 +05:30
before do
2018-03-17 18:26:18 +05:30
old_project.add_guest(user)
2016-06-02 11:05:42 +05:30
2018-03-17 18:26:18 +05:30
visit issue_path(issue)
2016-06-02 11:05:42 +05:30
end
2018-11-08 19:23:39 +05:30
it 'moving issue to another project not allowed' do
2023-04-23 21:23:45 +05:30
expect(page).to have_no_selector('.js-issuable-move-block')
2016-06-02 11:05:42 +05:30
end
end
context 'user has permission to move issue' do
let!(:mr) { create(:merge_request, source_project: old_project) }
let(:new_project) { create(:project) }
let(:new_project_search) { create(:project) }
2017-08-17 22:00:37 +05:30
let(:text) { "Text with #{mr.to_reference}" }
2020-03-13 15:44:24 +05:30
let(:cross_reference) { old_project.to_reference_base(new_project) }
2016-06-02 11:05:42 +05:30
2018-11-08 19:23:39 +05:30
before do
2018-03-17 18:26:18 +05:30
old_project.add_reporter(user)
new_project.add_reporter(user)
2016-06-02 11:05:42 +05:30
2018-03-17 18:26:18 +05:30
visit issue_path(issue)
2016-06-02 11:05:42 +05:30
end
2018-11-08 19:23:39 +05:30
it 'moving issue to another project', :js do
2023-04-23 21:23:45 +05:30
click_button _('Move issue')
2018-03-17 18:26:18 +05:30
wait_for_requests
2023-04-23 21:23:45 +05:30
all('.gl-dropdown-item')[0].click
click_button _('Move')
2016-06-02 11:05:42 +05:30
2017-08-17 22:00:37 +05:30
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-06-02 11:05:42 +05:30
expect(page).to have_content(issue.title)
2022-05-07 20:08:51 +05:30
expect(page).to have_current_path(%r(#{project_path(new_project)}))
2016-06-02 11:05:42 +05:30
end
2018-11-08 19:23:39 +05:30
it 'searching project dropdown', :js do
2018-03-17 18:26:18 +05:30
new_project_search.add_reporter(user)
2023-04-23 21:23:45 +05:30
click_button _('Move issue')
2018-03-17 18:26:18 +05:30
wait_for_requests
2023-04-23 21:23:45 +05:30
page.within '.js-issuable-move-block' do
fill_in(_('Search project'), with: new_project_search.name)
expect(page).to have_content(new_project_search.name)
expect(page).not_to have_content(new_project.name)
end
end
2018-03-17 18:26:18 +05:30
context 'user does not have permission to move the issue to a project', :js do
2016-06-02 11:05:42 +05:30
let!(:private_project) { create(:project, :private) }
let(:another_project) { create(:project) }
2020-01-01 13:55:28 +05:30
2018-11-08 19:23:39 +05:30
before do
another_project.add_guest(user)
end
2016-06-02 11:05:42 +05:30
2018-11-08 19:23:39 +05:30
it 'browsing projects in projects select' do
2023-04-23 21:23:45 +05:30
click_button _('Move issue')
2018-03-17 18:26:18 +05:30
wait_for_requests
2023-04-23 21:23:45 +05:30
page.within '.js-issuable-move-block' do
2018-03-27 19:54:05 +05:30
expect(page).to have_content new_project.full_name
end
2016-06-02 11:05:42 +05:30
end
end
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-11-08 19:23:39 +05:30
it 'user wants to move issue that has already been moved' do
expect(page).to have_no_selector('#move_to_project_id')
2016-06-02 11:05:42 +05:30
end
end
end
2023-05-27 22:25:52 +05:30
context 'service desk issue moved to a project with service desk disabled', :saas, :js do
2020-07-28 23:09:34 +05:30
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
2023-06-20 00:43:36 +05:30
allow(Gitlab::Email::IncomingEmail).to receive(:enabled?).and_return(true)
allow(Gitlab::Email::IncomingEmail).to receive(:supports_wildcard?).and_return(true)
2020-07-28 23:09:34 +05:30
regular_project.add_reporter(user)
service_desk_project.add_reporter(user)
visit issue_path(service_desk_issue)
2023-04-23 21:23:45 +05:30
click_button _('Move issue')
2020-07-28 23:09:34 +05:30
wait_for_requests
2023-04-23 21:23:45 +05:30
find('.gl-dropdown-item', text: project_title).click
click_button _('Move')
2020-07-28 23:09:34 +05:30
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-06-02 11:05:42 +05:30
def issue_path(issue)
2017-09-10 17:25:29 +05:30
project_issue_path(issue.project, issue)
2016-06-02 11:05:42 +05:30
end
end