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
Add API link to the copied project on success
Oliver Günther5ecb700610ab
diff --git a/app/workers/copy_project_job.rb b/app/workers/copy_project_job.rbindex 75aae3cc35a..18bb63b0567 100644--- a/app/workers/copy_project_job.rb+++ b/app/workers/copy_project_job.rb@@ -91,6 +91,7 @@ class CopyProjectJob < ApplicationJobdef successful_status_updatepayload = redirect_payload(url_helpers.project_url(target_project))+ .merge(hal_links(target_project))if errors.any?payload[:errors] = errors@@ -111,6 +112,17 @@ class CopyProjectJob < ApplicationJobupsert_status status: :failure, message:end+ def hal_links(project)+ {+ _links: {+ project: {+ href: ::API::V3::Utilities::PathHelper::ApiV3Path.project(project.id),+ title: project.name+ }+ }+ }+ end+def user@user ||= User.find user_idenddiff --git a/spec/workers/copy_project_job_spec.rb b/spec/workers/copy_project_job_spec.rbindex 992f9aa5854..d58e6d7cdeb 100644--- a/spec/workers/copy_project_job_spec.rb+++ b/spec/workers/copy_project_job_spec.rb@@ -92,6 +92,7 @@ describe CopyProjectJob, type: :model do"#{WorkPackage.model_name.human} '#{work_package.type.name} ##{work_package.id}: #{work_package.subject}': #{custom_field.name} #{I18n.t('errors.messages.blank')}."end+ # rubocop:disable RSpec/InstanceVariablebefore dosource_project.work_package_custom_fields << custom_fieldtype.custom_fields << custom_field@@ -110,8 +111,12 @@ describe CopyProjectJob, type: :model doexpect(copy_job.job_status).to be_presentexpect(copy_job.job_status[:status]).to eq 'success'expect(copy_job.job_status[:payload]['redirect']).to include '/projects/copy'++ expected_link = { 'href' => "/api/v3/projects/#{@copied_project.id}", 'title' => @copied_project.name }+ expect(copy_job.job_status[:payload]['_links']['project']).to eq(expected_link)endend+ # rubocop:enable RSpec/InstanceVariabledescribe 'project has an invalid repository' dolet(:admin) { create(:admin) }