]> source.dussan.org Git - redmine.git/commitdiff
Reverts r12669 and add a test for #15870.
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Thu, 30 Jan 2014 22:18:07 +0000 (22:18 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Thu, 30 Jan 2014 22:18:07 +0000 (22:18 +0000)
git-svn-id: http://svn.redmine.org/redmine/trunk@12739 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/models/issue.rb
test/unit/issue_nested_set_test.rb

index 383b41bc9282f3d574bb0b15630ce2f00a562ef6..106b7e77b7f9336bd6fdba52b18a92dc7d78fe60 100644 (file)
@@ -1364,7 +1364,6 @@ class Issue < ActiveRecord::Base
                 "* (CASE WHEN is_closed = #{connection.quoted_true} THEN 100 ELSE COALESCE(done_ratio, 0) END)").to_f
           progress = done / (average * leaves_count)
           p.done_ratio = progress.round
-          p.done_ratio = 100 if p.done_ratio > 100
         end
       end
 
index 3649e97a72a616ab34ec516c0d0e6a614c427bf8..f3bfddbf2b37da596663ab21d70047eede6b509f 100644 (file)
@@ -356,6 +356,19 @@ class IssueNestedSetTest < ActiveSupport::TestCase
     assert_equal 12, parent.reload.estimated_hours
   end
 
+  def test_done_ratio_of_parent_with_a_child_without_estimated_time_should_not_exceed_100
+    parent = Issue.generate!
+    Issue.generate!(:estimated_hours => 40, :parent_issue_id => parent.id)
+    Issue.generate!(:estimated_hours => 40, :parent_issue_id => parent.id)
+    Issue.generate!(:estimated_hours => 20, :parent_issue_id => parent.id)
+    Issue.generate!(:parent_issue_id => parent.id)
+    parent.reload.children.each do |child|
+      child.update_attribute :status_id, 5
+      puts parent.reload.done_ratio
+    end
+    assert_equal 100, parent.reload.done_ratio
+  end
+
   def test_move_parent_updates_old_parent_attributes
     first_parent = Issue.generate!
     second_parent = Issue.generate!