diff --git a/spec/controllers/work_packages/moves_controller_spec.rb b/spec/controllers/work_packages/moves_controller_spec.rb
index 6b3785a921..47673480bd 100644
--- a/spec/controllers/work_packages/moves_controller_spec.rb
+++ b/spec/controllers/work_packages/moves_controller_spec.rb
@@ -36,6 +36,7 @@ describe WorkPackages::MovesController, type: :controller do
view_work_packages
add_work_packages
edit_work_packages
+ assign_versions
manage_subtasks)
end
let(:type) { FactoryBot.create :type }
@@ -316,6 +317,10 @@ describe WorkPackages::MovesController, type: :controller do
expect(subject.status_id).to eq(work_package.status_id)
end
+ it 'did not change the status' do
+ expect(subject.fixed_version_id).to eq(work_package.fixed_version_id)
+ end
+
it 'did not change the assignee' do
expect(subject.assigned_to_id).to eq(work_package.assigned_to_id)
end
@@ -328,6 +333,7 @@ describe WorkPackages::MovesController, type: :controller do
context "with changing the work package's attribute" do
let(:start_date) { Date.today }
let(:due_date) { Date.today + 1 }
+ let(:target_version) { FactoryBot.create(:version, project: target_project) }
let(:target_user) do
user = FactoryBot.create :user
@@ -349,6 +355,7 @@ describe WorkPackages::MovesController, type: :controller do
assigned_to_id: target_user.id,
responsible_id: target_user.id,
status_id: target_status,
+ fixed_version_id: target_version.id,
start_date: start_date,
due_date: due_date
}
@@ -384,6 +391,12 @@ describe WorkPackages::MovesController, type: :controller do
end
end
+ it 'did change the version' do
+ subject.map(&:fixed_version_id).each do |id|
+ expect(id).to eq(target_version.id)
+ end
+ end
+
it 'did change the start date' do
subject.map(&:start_date).each do |date|
expect(date).to eq(start_date)
diff --git a/spec/features/work_packages/bulk/copy_work_package_spec.rb b/spec/features/work_packages/bulk/copy_work_package_spec.rb
index 189a63ccb5..28d70a7868 100644
--- a/spec/features/work_packages/bulk/copy_work_package_spec.rb
+++ b/spec/features/work_packages/bulk/copy_work_package_spec.rb
@@ -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