@@ -1364,7 +1364,6 class Issue < ActiveRecord::Base | |||||
1364 | "* (CASE WHEN is_closed = #{connection.quoted_true} THEN 100 ELSE COALESCE(done_ratio, 0) END)").to_f |
|
1364 | "* (CASE WHEN is_closed = #{connection.quoted_true} THEN 100 ELSE COALESCE(done_ratio, 0) END)").to_f | |
1365 | progress = done / (average * leaves_count) |
|
1365 | progress = done / (average * leaves_count) | |
1366 | p.done_ratio = progress.round |
|
1366 | p.done_ratio = progress.round | |
1367 | p.done_ratio = 100 if p.done_ratio > 100 |
|
|||
1368 | end |
|
1367 | end | |
1369 | end |
|
1368 | end | |
1370 |
|
1369 |
@@ -356,6 +356,19 class IssueNestedSetTest < ActiveSupport::TestCase | |||||
356 | assert_equal 12, parent.reload.estimated_hours |
|
356 | assert_equal 12, parent.reload.estimated_hours | |
357 | end |
|
357 | end | |
358 |
|
358 | |||
|
359 | def test_done_ratio_of_parent_with_a_child_without_estimated_time_should_not_exceed_100 | |||
|
360 | parent = Issue.generate! | |||
|
361 | Issue.generate!(:estimated_hours => 40, :parent_issue_id => parent.id) | |||
|
362 | Issue.generate!(:estimated_hours => 40, :parent_issue_id => parent.id) | |||
|
363 | Issue.generate!(:estimated_hours => 20, :parent_issue_id => parent.id) | |||
|
364 | Issue.generate!(:parent_issue_id => parent.id) | |||
|
365 | parent.reload.children.each do |child| | |||
|
366 | child.update_attribute :status_id, 5 | |||
|
367 | puts parent.reload.done_ratio | |||
|
368 | end | |||
|
369 | assert_equal 100, parent.reload.done_ratio | |||
|
370 | end | |||
|
371 | ||||
359 | def test_move_parent_updates_old_parent_attributes |
|
372 | def test_move_parent_updates_old_parent_attributes | |
360 | first_parent = Issue.generate! |
|
373 | first_parent = Issue.generate! | |
361 | second_parent = Issue.generate! |
|
374 | second_parent = Issue.generate! |
General Comments 0
You need to be logged in to leave comments.
Login now