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
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Copy attachments for work packages too
Oliver Günther48e75b07abc2
diff --git a/app/services/work_packages/copy_service.rb b/app/services/work_packages/copy_service.rbindex c23bb160244..6f2f0e0616b 100644--- a/app/services/work_packages/copy_service.rb+++ b/app/services/work_packages/copy_service.rb@@ -105,6 +105,11 @@ class WorkPackages::CopyServiceenddef copy_work_package_attachments(copy)- copy_attachments('WorkPackage', from_id: work_package.id, to_id: copy.id)+ copy_attachments(+ 'WorkPackage',+ from: work_package,+ to: copy,+ references: %i[description]+ )endenddiff --git a/spec/services/work_packages/copy_service_integration_spec.rb b/spec/services/work_packages/copy_service_integration_spec.rbindex 1f964497c95..cde3bb89f09 100644--- a/spec/services/work_packages/copy_service_integration_spec.rb+++ b/spec/services/work_packages/copy_service_integration_spec.rb@@ -316,6 +316,30 @@ RSpec.describe WorkPackages::CopyService, 'integration', type: :model doendend+ context 'when referencing the attachment in the description' do+ let(:text) do+ <<~MARKDOWN+ # Some text here++ + MARKDOWN+ end++ before do+ work_package.update_column(:description, text)+ end++ it 'updates the attachment reference' do+ expect(work_package.description).to include "/api/v3/attachments/#{attachment.id}/content"++ expect(copy.attachments.length).to eq 1+ expect(copy.attachments.first.id).not_to eq attachment.id++ expect(copy.description).not_to include "/api/v3/attachments/#{attachment.id}/content"+ expect(copy.description).to include "/api/v3/attachments/#{copy.attachments.first.id}/content"+ end+ end+context 'when specifying to not copy attachments' dolet(:attributes) { { copy_attachments: false } }