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

added validation checking that work package is not part of a bcf issue already

Markus Kahl24aeaa0c6d5d
diff --git a/modules/bim/app/contracts/bim/bcf/issues/create_contract.rb b/modules/bim/app/contracts/bim/bcf/issues/create_contract.rb
index 71242bab262..3f4ac8b3a2a 100644
--- a/modules/bim/app/contracts/bim/bcf/issues/create_contract.rb
+++ b/modules/bim/app/contracts/bim/bcf/issues/create_contract.rb
@@ -30,7 +30,11 @@ module Bim::Bcf
module Issues
class CreateContract < BaseContract
attribute :uuid
- attribute :work_package
+ attribute :work_package do
+ if work_package.bcf_issue.present?
+ errors.add :work_package, :taken
+ end
+ end
end
end
end
diff --git a/modules/bim/spec/requests/api/bcf/v2_1/topics_api_spec.rb b/modules/bim/spec/requests/api/bcf/v2_1/topics_api_spec.rb
index 932364aa92b..e3a7644b2a0 100644
--- a/modules/bim/spec/requests/api/bcf/v2_1/topics_api_spec.rb
+++ b/modules/bim/spec/requests/api/bcf/v2_1/topics_api_spec.rb
@@ -709,6 +709,21 @@ describe 'BCF 2.1 topics resource', type: :request, content_type: :json, with_ma
expect(response.body).to include "The requested resource could not be found."
end
end
+
+ context 'with a work package that already belongs to a BCF issue' do
+ let(:params) do
+ {
+ title: "A BCF topic that shouldn't be",
+ reference_links: [
+ api_v3_paths.work_package(bcf_issue.work_package.id)
+ ]
+ }
+ end
+
+ it_behaves_like 'bcf api unprocessable response' do
+ let(:message) { "Work package has already been taken." }
+ end
+ end
end
it_behaves_like 'topics api write invalid parameters errors'