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

[55656] Remove derivedRemainingTime from form payload

Christophe Bliard5ee2ba5cca17
diff --git a/lib/api/utilities/payload_representer.rb b/lib/api/utilities/payload_representer.rb
index 50aa1bbbeb7..60aa6857e9b 100644
--- a/lib/api/utilities/payload_representer.rb
+++ b/lib/api/utilities/payload_representer.rb
@@ -51,12 +51,15 @@ module API
# Note: `:writeable` is not a typo, it's used by declarative gem
writable = property[:writeable]
+
+ # If writable is a lambda, rely on it to determine if the property should be output
+ # else if writable is explicitly false, do not output the property
+ # else rely on #writable_attributes (through UnwritablePropertyFilter) to know if the property should be output
+ next if writable.respond_to?(:call)
+
if writable == false
property.merge!(readable: false)
- end
-
- # Only filter unwritable if not a lambda
- unless writable.respond_to?(:call)
+ else
add_filter(property, UnwritablePropertyFilter)
end
end
diff --git a/lib/api/v3/work_packages/work_package_representer.rb b/lib/api/v3/work_packages/work_package_representer.rb
index b282a43722c..8794762cec3 100644
--- a/lib/api/v3/work_packages/work_package_representer.rb
+++ b/lib/api/v3/work_packages/work_package_representer.rb
@@ -418,7 +418,6 @@ module API
datetime_formatter.format_duration_from_hours(represented.derived_remaining_hours,
allow_nil: true)
end,
- writable: ->(*) { !WorkPackage.use_status_for_done_ratio? },
render_nil: true
property :duration,
diff --git a/spec/lib/api/v3/work_packages/work_package_payload_representer_spec.rb b/spec/lib/api/v3/work_packages/work_package_payload_representer_spec.rb
index 25f288df2ae..e5095d5eaf9 100644
--- a/spec/lib/api/v3/work_packages/work_package_payload_representer_spec.rb
+++ b/spec/lib/api/v3/work_packages/work_package_payload_representer_spec.rb
@@ -133,6 +133,14 @@ RSpec.describe API::V3::WorkPackages::WorkPackagePayloadRepresenter do
end
end
+ describe "derived remaining hours" do
+ context "when set" do
+ let(:work_package) { build(:work_package, derived_remaining_hours: 5) }
+
+ it { is_expected.not_to have_json_path("derivedRemainingTime") }
+ end
+ end
+
describe "startDate" do
before do
allow(work_package)