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

[#66093] Do not hardcode `customized_type` in API

Tobias Dillmannba9eb9b830ac
diff --git a/lib/api/v3/utilities/custom_field_injector.rb b/lib/api/v3/utilities/custom_field_injector.rb
index 23c19b1d84b..2d81b66cee3 100644
--- a/lib/api/v3/utilities/custom_field_injector.rb
+++ b/lib/api/v3/utilities/custom_field_injector.rb
@@ -312,7 +312,7 @@ module API
next unless custom_field.calculated_value?
next unless available_custom_fields.include?(custom_field)
- errors = custom_field.calculated_value_errors.where(customized_id: id, customized_type: "Project")
+ errors = custom_field.calculated_value_errors.where(customized: self)
errors.map do |err|
{ code: err.error_code,
message: CalculatedValues::ErrorsHelper.calculated_value_error_msg(err) }
diff --git a/spec/lib/api/v3/projects/project_representer_rendering_spec.rb b/spec/lib/api/v3/projects/project_representer_rendering_spec.rb
index 6d00631ebef..23b35e6782d 100644
--- a/spec/lib/api/v3/projects/project_representer_rendering_spec.rb
+++ b/spec/lib/api/v3/projects/project_representer_rendering_spec.rb
@@ -226,7 +226,7 @@ RSpec.describe API::V3::Projects::ProjectRepresenter, "rendering" do
before do
value_errors_double = double
allow(value_errors_double).to receive(:where)
- .with(customized_id: project.id, customized_type: "Project")
+ .with(customized: project)
.and_return([calculated_value_error])
allow(calculated_value_custom_field).to receive(:calculated_value_errors)