Merge pull request #10534 from fraber/bug/40867-wrong-progress-value-in-parent-task-estimated-hours

[#40867] Wrong progress value in parent task - Estimated hours
pull/10576/head
ulferts 3 years ago committed by GitHub
commit 447260926c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 10
      app/services/work_packages/update_ancestors_service.rb
  2. 6
      spec/services/work_packages/update_ancestors_service_spec.rb

@ -91,8 +91,16 @@ class WorkPackages::UpdateAncestorsService
def inherit_attributes(ancestor, attributes)
return unless attributes_justify_inheritance?(attributes)
# Estimated hours need to be calculated before the done_ratio below.
# The aggregation only depends on estimated hours.
derive_estimated_hours(ancestor) if inherit?(attributes, :estimated_hours)
inherit_done_ratio(ancestor) if inherit?(attributes, :done_ratio)
# Progress (done_ratio or also: percentDone) depends on both
# the completion of sub-WPs, as well as the estimated hours
# as a weight factor. So changes in estimated hours also have
# to trigger a recalculation of done_ratio.
#
inherit_done_ratio(ancestor) if inherit?(attributes, :done_ratio) || inherit?(attributes, :estimated_hours)
end
def inherit?(attributes, attribute)

@ -76,10 +76,14 @@ describe WorkPackages::UpdateAncestorsService, type: :model, with_mail: false do
let(:parent) { create :work_package, status: open_status }
subject do
# In the call we only use estimated_hours (instead of also adding
# done_ratio) in order to test that changes in estimated hours
# trigger a recalculation of done_ration, because estimated hours
# act as weights in this calculation.
described_class
.new(user: user,
work_package: children.first)
.call(%i(done_ratio estimated_hours))
.call(%i(estimated_hours))
end
context 'with no estimated hours and no progress' do

Loading…
Cancel
Save