2016-03-16 10:11:07 -04:00
|
|
|
require 'rails_helper'
|
|
|
|
|
|
|
|
feature 'issue move to another project' do
|
|
|
|
let(:user) { create(:user) }
|
|
|
|
let(:old_project) { create(:project) }
|
|
|
|
let(:text) { 'Some issue description' }
|
|
|
|
|
|
|
|
let(:issue) do
|
|
|
|
create(:issue, description: text, project: old_project, author: user)
|
|
|
|
end
|
|
|
|
|
|
|
|
background { login_as(user) }
|
|
|
|
|
|
|
|
context 'user does not have permission to move issue' do
|
|
|
|
background do
|
|
|
|
old_project.team << [user, :guest]
|
|
|
|
|
|
|
|
edit_issue(issue)
|
|
|
|
end
|
|
|
|
|
|
|
|
scenario 'moving issue to another project not allowed' do
|
2016-05-16 12:17:40 -04:00
|
|
|
expect(page).to have_no_selector('#move_to_project_id')
|
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) }
|
|
|
|
let(:new_project) { create(:project) }
|
2016-06-15 06:34:11 -04:00
|
|
|
let(:new_project_search) { create(:project) }
|
2016-11-23 01:55:23 -05:00
|
|
|
let(:text) { "Text with #{mr.to_reference}" }
|
2016-11-02 19:49:13 -04:00
|
|
|
let(:cross_reference) { old_project.to_reference(new_project) }
|
2016-03-16 10:11:07 -04:00
|
|
|
|
|
|
|
background do
|
|
|
|
old_project.team << [user, :reporter]
|
|
|
|
new_project.team << [user, :reporter]
|
|
|
|
|
|
|
|
edit_issue(issue)
|
|
|
|
end
|
|
|
|
|
2017-04-05 21:13:06 -04:00
|
|
|
scenario 'moving issue to another project', js: true do
|
2017-05-25 07:50:11 -04:00
|
|
|
find('#issuable-move', visible: false).set(new_project.id)
|
2016-03-16 10:11:07 -04:00
|
|
|
click_button('Save changes')
|
|
|
|
|
2017-05-25 07:50:11 -04:00
|
|
|
wait_for_requests
|
|
|
|
|
2016-03-16 10:11:07 -04:00
|
|
|
expect(current_url).to include project_path(new_project)
|
|
|
|
|
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)
|
2016-03-16 10:11:07 -04:00
|
|
|
end
|
|
|
|
|
2016-06-15 06:34:11 -04:00
|
|
|
scenario 'searching project dropdown', js: true do
|
|
|
|
new_project_search.team << [user, :reporter]
|
|
|
|
|
2017-05-25 07:50:11 -04:00
|
|
|
page.within '.detail-page-description' do
|
2016-06-15 06:34:11 -04:00
|
|
|
first('.select2-choice').click
|
|
|
|
end
|
|
|
|
|
2016-07-16 03:12:12 -04:00
|
|
|
fill_in('s2id_autogen1_search', with: new_project_search.name)
|
2016-06-15 06:34:11 -04:00
|
|
|
|
|
|
|
page.within '.select2-drop' do
|
|
|
|
expect(page).to have_content(new_project_search.name)
|
|
|
|
expect(page).not_to have_content(new_project.name)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-05-20 16:52:45 -04:00
|
|
|
context 'user does not have permission to move the issue to a project', js: true do
|
2016-03-16 10:11:07 -04:00
|
|
|
let!(:private_project) { create(:project, :private) }
|
|
|
|
let(:another_project) { create(:project) }
|
|
|
|
background { another_project.team << [user, :guest] }
|
|
|
|
|
|
|
|
scenario 'browsing projects in projects select' do
|
2017-05-25 07:50:11 -04:00
|
|
|
click_link 'Move to a different project'
|
2016-05-16 12:17:40 -04:00
|
|
|
|
|
|
|
page.within '.select2-results' do
|
|
|
|
expect(page).to have_content 'No project'
|
|
|
|
expect(page).to have_content new_project.name_with_namespace
|
|
|
|
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
|
|
|
|
|
|
|
|
scenario '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
|
|
|
|
|
|
|
|
def edit_issue(issue)
|
|
|
|
visit issue_path(issue)
|
2016-04-12 11:27:16 -04:00
|
|
|
page.within('.issuable-actions') { first(:link, 'Edit').click }
|
2016-03-16 10:11:07 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def issue_path(issue)
|
|
|
|
namespace_project_issue_path(issue.project.namespace, issue.project, issue)
|
|
|
|
end
|
|
|
|
|
|
|
|
def project_path(project)
|
|
|
|
namespace_project_path(new_project.namespace, new_project)
|
|
|
|
end
|
|
|
|
end
|