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

Detect cases where work is not changed but set by user nonetheless

Christophe Bliard757700db1510
diff --git a/app/services/work_packages/set_attributes_service.rb b/app/services/work_packages/set_attributes_service.rb
index 605ac8cdadc..850c23e4759 100644
--- a/app/services/work_packages/set_attributes_service.rb
+++ b/app/services/work_packages/set_attributes_service.rb
@@ -372,7 +372,7 @@ class WorkPackages::SetAttributesService < BaseServices::SetAttributes
def update_estimated_hours
return unless WorkPackage.use_field_for_done_ratio?
- return if work_package.estimated_hours_changed?
+ return if work_package.estimated_hours_came_from_user?
return unless work_package.remaining_hours_changed?
work = work_package.estimated_hours
diff --git a/spec/services/work_packages/set_attributes_service_spec.rb b/spec/services/work_packages/set_attributes_service_spec.rb
index bbf4d5b010f..08b3beee5d8 100644
--- a/spec/services/work_packages/set_attributes_service_spec.rb
+++ b/spec/services/work_packages/set_attributes_service_spec.rb
@@ -663,6 +663,16 @@ RSpec.describe WorkPackages::SetAttributesService,
description: "is an error state (to be detected by contract), " \
"and % complete and work are kept"
end
+
+ context "when remaining work is set and work is unset" do
+ let(:call_attributes) { { estimated_hours: nil, remaining_hours: 6.7 } }
+ let(:expected_attributes) { call_attributes.dup }
+ let(:expected_kept_attributes) { %w[done_ratio] }
+
+ it_behaves_like "service call",
+ description: "% complete is kept and work is kept unset and not recomputed" \
+ "(error state to be detected by contract)"
+ end
end
end
end