Project

General

Profile

Defect #33576 » fix-33576-v2.patch

Go MAEDA, 2020-06-10 11:33

View differences:

app/models/issue.rb
if children.any?
child_with_total_estimated_hours = children.select {|c| c.total_estimated_hours.to_f > 0.0}
if child_with_total_estimated_hours.any?
average = child_with_total_estimated_hours.map(&:total_estimated_hours).sum.to_f / child_with_total_estimated_hours.count
average = child_with_total_estimated_hours.map(&:total_estimated_hours).sum.to_d / child_with_total_estimated_hours.count
else
average = 1.0
average = 1.0.to_d
end
done = children.map {|c|
estimated = c.total_estimated_hours.to_f
estimated = c.total_estimated_hours.to_d
estimated = average unless estimated > 0.0
ratio = c.closed? ? 100 : (c.done_ratio || 0)
estimated * ratio
test/unit/issue_subtasking_test.rb
end
end
def test_parent_done_ratio_with_completed_children_should_not_be_99
with_settings :parent_issue_done_ratio => 'derived' do
parent = Issue.generate!
parent.generate_child!(:estimated_hours => 8.0, :done_ratio => 100)
parent.generate_child!(:estimated_hours => 8.1, :done_ratio => 100)
# (8.0 * 100 + 8.1 * 100) / (8.0 + 8.1) => 99.99999999999999
assert_equal 100, parent.reload.done_ratio
end
end
def test_done_ratio_of_parent_with_a_child_without_estimated_time_should_not_exceed_100
with_settings :parent_issue_done_ratio => 'derived' do
parent = Issue.generate!
(3-3/3)