|
|
|
@ -8,7 +8,7 @@ describe 'Copy work packages through Rails view', js: true do |
|
|
|
|
end |
|
|
|
|
let(:mover_role) do |
|
|
|
|
FactoryBot.create :role, |
|
|
|
|
permissions: %i[view_work_packages copy_work_packages move_work_packages manage_subtasks add_work_packages] |
|
|
|
|
permissions: %i[view_work_packages copy_work_packages move_work_packages manage_subtasks assign_versions add_work_packages] |
|
|
|
|
end |
|
|
|
|
let(:dev) do |
|
|
|
|
FactoryBot.create :user, |
|
|
|
@ -45,6 +45,7 @@ describe 'Copy work packages through Rails view', js: true do |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
let(:status) { work_package.status } |
|
|
|
|
let!(:version) { FactoryBot.create :version, project: project2 } |
|
|
|
|
let!(:status2) { FactoryBot.create :default_status } |
|
|
|
|
let!(:workflow) do |
|
|
|
|
FactoryBot.create :workflow, |
|
|
|
@ -73,36 +74,62 @@ describe 'Copy work packages through Rails view', js: true do |
|
|
|
|
let(:current_user) { mover } |
|
|
|
|
|
|
|
|
|
before do |
|
|
|
|
wp_table.expect_work_package_count 2 |
|
|
|
|
context_menu.open_for work_package |
|
|
|
|
context_menu.choose 'Bulk copy' |
|
|
|
|
|
|
|
|
|
# On work packages move page |
|
|
|
|
expect(page).to have_selector('#new_project_id') |
|
|
|
|
select 'Target', from: 'new_project_id' |
|
|
|
|
click_on 'Copy and follow' |
|
|
|
|
|
|
|
|
|
sleep 1 |
|
|
|
|
|
|
|
|
|
expect(page).to have_select('Project', selected: 'Target') |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it 'moves parent and child wp to a new project' do |
|
|
|
|
expect_angular_frontend_initialized |
|
|
|
|
it 'sets the version on copy' do |
|
|
|
|
select version.name, from: 'fixed_version_id' |
|
|
|
|
click_on 'Copy and follow' |
|
|
|
|
|
|
|
|
|
wp_table.expect_work_package_count 2 |
|
|
|
|
expect(page).to have_selector('#projects-menu', text: 'Target') |
|
|
|
|
|
|
|
|
|
# Should not move the sources |
|
|
|
|
work_package2.reload |
|
|
|
|
work_package.reload |
|
|
|
|
expect(work_package.project_id).to eq(project.id) |
|
|
|
|
expect(work_package2.project_id).to eq(project.id) |
|
|
|
|
|
|
|
|
|
# Check project of last two created wps |
|
|
|
|
copied_wps = WorkPackage.last(2) |
|
|
|
|
expect(copied_wps.map(&:project_id)).to eq([project2.id, project2.id]) |
|
|
|
|
expect(copied_wps.map(&:project_id).uniq).to eq([project2.id]) |
|
|
|
|
expect(copied_wps.map(&:fixed_version_id).uniq).to eq([version.id]) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context 'when the target project does not have the type' do |
|
|
|
|
let!(:project2) { FactoryBot.create(:project, name: 'Target', types: [type2]) } |
|
|
|
|
describe 'copy and follow' do |
|
|
|
|
before do |
|
|
|
|
click_on 'Copy and follow' |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it 'moves parent and child wp to a new project' do |
|
|
|
|
expect_angular_frontend_initialized |
|
|
|
|
wp_table.expect_work_package_count 2 |
|
|
|
|
expect(page).to have_selector('#projects-menu', text: 'Target') |
|
|
|
|
|
|
|
|
|
# Should not move the sources |
|
|
|
|
work_package2.reload |
|
|
|
|
work_package.reload |
|
|
|
|
expect(work_package.project_id).to eq(project.id) |
|
|
|
|
expect(work_package2.project_id).to eq(project.id) |
|
|
|
|
|
|
|
|
|
# Check project of last two created wps |
|
|
|
|
copied_wps = WorkPackage.last(2) |
|
|
|
|
expect(copied_wps.map(&:project_id)).to eq([project2.id, project2.id]) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context 'when the target project does not have the type' do |
|
|
|
|
let!(:project2) { FactoryBot.create(:project, name: 'Target', types: [type2]) } |
|
|
|
|
|
|
|
|
|
it 'does moves the work package and changes the type' do |
|
|
|
|
expect(page).to have_selector('.flash.error', text: "Failed to save 2 work package(s) on 2 selected:") |
|
|
|
|
it 'does moves the work package and changes the type' do |
|
|
|
|
expect(page).to have_selector('.flash.error', text: "Failed to save 2 work package(s) on 2 selected:") |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|