Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Merge remote-tracking branch 'origin/dev' into implementation/49248-copy-filelinks-respecting-the-location-of-the-files

Pavel Balashou6261a00524dc
diff --cc spec/services/projects/copy_service_integration_spec.rb
index 6adb1ecc86b,8abf4854f03..48923d612ea
--- a/spec/services/projects/copy_service_integration_spec.rb
+++ b/spec/services/projects/copy_service_integration_spec.rb
@@@ -806,119 -678,71 +806,120 @@@ RSpec.describe
.to be_nil
end
end
- end
- describe 'assigned_to' do
- let(:assigned_user) do
- create(:user,
- member_in_project: source,
- member_through_role: role)
- end
+ context 'when work_package is assigned to somebody' do
+ let(:assigned_user) do
+ create(:user,
+ member_in_project: source,
+ member_through_role: role)
+ end
- before do
- work_package.update_column(:assigned_to_id, assigned_user.id)
- end
+ before do
+ work_package.update_column(:assigned_to_id, assigned_user.id)
+ end
- context 'with the members being copied' do
- let(:only_args) { %w[members work_packages] }
+ context 'with the members being copied' do
+ let(:only_args) { %w[members work_packages] }
- it 'copies the assigned_to' do
- expect(subject).to be_success
- expect(project_copy.work_packages[0].assigned_to)
- .to eql assigned_user
- # The assignee of the new work package receives a notification
- expect { perform_enqueued_jobs }
- .to change(Notification.where(recipient: assigned_user), :count)
- .from(0)
- .to(1)
+ it 'copies the assigned_to' do
+ expect(subject).to be_success
+ expect(project_copy.work_packages[0].assigned_to)
+ .to eql assigned_user
+ # The assignee of the new work package receives a notification
+ expect { perform_enqueued_jobs }
+ .to change(Notification.where(recipient: assigned_user), :count)
+ .from(0)
+ .to(1)
+ end
end
- end
- context 'with the assignee not being a member' do
- let(:only_args) { %w[work_packages] }
+ context 'with the member being not copied' do
+ let(:only_args) { %w[work_packages] }
- it 'nils the assigned_to' do
- expect(subject).to be_success
- expect(project_copy.work_packages[0].assigned_to)
- .to be_nil
- # No notification is sent out
- expect { perform_enqueued_jobs }
- .not_to change(Notification.where(recipient: assigned_user), :count)
+ it 'nils the assigned_to' do
+ expect(subject).to be_success
+ expect(project_copy.work_packages[0].assigned_to)
+ .to be_nil
+ # No notification is sent out
+ expect { perform_enqueued_jobs }
+ .not_to change(Notification.where(recipient: assigned_user), :count)
+ end
end
end
- end
- describe 'responsible' do
- let(:responsible_user) do
- create(:user,
- member_in_project: source,
- member_through_role: role)
- end
+ context 'when work_package has a responsible person' do
+ let(:responsible_user) do
+ create(:user,
+ member_in_project: source,
+ member_through_role: role)
+ end
- before do
- work_package.update_column(:responsible_id, responsible_user.id)
+ before do
+ work_package.update_column(:responsible_id, responsible_user.id)
+ end
+
+ context 'with the members being copied' do
+ let(:only_args) { %w[members work_packages] }
+
+ it 'copies the responsible' do
+ expect(subject).to be_success
+ expect(project_copy.work_packages[0].responsible)
+ .to eql responsible_user
+ # The responsible of the new work package receives a notification
+ expect { perform_enqueued_jobs }
+ .to change(Notification.where(recipient: responsible_user), :count)
+ .from(0)
+ .to(1)
+ end
+ end
+
+ context 'with the member being not copied' do
+ let(:only_args) { %w[work_packages] }
+
+ it 'nils the assigned_to' do
+ expect(subject).to be_success
+ expect(project_copy.work_packages[0].responsible).to be_nil
+ # No notification is sent out
+ expect { perform_enqueued_jobs }
+ .not_to change(Notification.where(recipient: responsible_user), :count)
+ end
+ end
end
- context 'with the members being copied' do
- let(:only_args) { %w[members work_packages] }
+ describe 'work package user custom field' do
+ let(:custom_field) do
+ create(:user_wp_custom_field).tap do |cf|
+ source.work_package_custom_fields << cf
+ work_package.type.custom_fields << cf
+ end
+ end
- it 'copies the responsible' do
- expect(subject).to be_success
- expect(project_copy.work_packages[0].responsible)
- .to eql responsible_user
- # The responsible of the new work package receives a notification
- expect { perform_enqueued_jobs }
- .to change(Notification.where(recipient: responsible_user), :count)
- .from(0)
- .to(1)
+ before do
+ custom_field
- work_package.reload
++ # Void the custom field caching
++ RequestStore.clear!
+ work_package.send(custom_field.attribute_setter, current_user.id)
+ work_package.save!(validate: false)
+ end
+
+ context 'with the member being copied' do
+ let(:only_args) { %w[members work_packages] }
+
+ it 'copies the custom_field' do
+ expect(subject).to be_success
+ wp = project_copy.work_packages.find_by(subject: work_package.subject)
+ expect(wp.send(custom_field.attribute_getter)).to eql current_user
+ end
+ end
+
+ context 'with the member being not copied' do
+ let(:only_args) { %w[work_packages] }
+
+ it 'nils the custom_field' do
+ expect(subject).to be_success
+ wp = project_copy.work_packages.find_by(subject: work_package.subject)
+ expect(wp.send(custom_field.attribute_getter)).to be_nil
+ end
end
end