##// END OF EJS Templates
Fixes calculation of version estimated hours with subtasks (#5265)....
Jean-Philippe Lang -
r3519:71a4158fd049
parent child
Show More
@@ -52,8 +52,9 class Version < ActiveRecord::Base
52 end
52 end
53
53
54 # Returns the total estimated time for this version
54 # Returns the total estimated time for this version
55 # (sum of leaves estimated_hours)
55 def estimated_hours
56 def estimated_hours
56 @estimated_hours ||= fixed_issues.sum(:estimated_hours).to_f
57 @estimated_hours ||= fixed_issues.leaves.sum(:estimated_hours).to_f
57 end
58 end
58
59
59 # Returns the total reported time for this version
60 # Returns the total reported time for this version
@@ -104,6 +104,34 class VersionTest < ActiveSupport::TestCase
104 assert_progress_equal (25.0*0.2 + 25.0*1 + 10.0*0.3 + 40.0*0.1)/100.0*100, v.completed_pourcent
104 assert_progress_equal (25.0*0.2 + 25.0*1 + 10.0*0.3 + 40.0*0.1)/100.0*100, v.completed_pourcent
105 assert_progress_equal 25.0/100.0*100, v.closed_pourcent
105 assert_progress_equal 25.0/100.0*100, v.closed_pourcent
106 end
106 end
107
108 context "#estimated_hours" do
109 setup do
110 @version = Version.create!(:project_id => 1, :name => '#estimated_hours')
111 end
112
113 should "return 0 with no assigned issues" do
114 assert_equal 0, @version.estimated_hours
115 end
116
117 should "return 0 with no estimated hours" do
118 add_issue(@version)
119 assert_equal 0, @version.estimated_hours
120 end
121
122 should "return the sum of estimated hours" do
123 add_issue(@version, :estimated_hours => 2.5)
124 add_issue(@version, :estimated_hours => 5)
125 assert_equal 7.5, @version.estimated_hours
126 end
127
128 should "return the sum of leaves estimated hours" do
129 parent = add_issue(@version)
130 add_issue(@version, :estimated_hours => 2.5, :parent_issue_id => parent.id)
131 add_issue(@version, :estimated_hours => 5, :parent_issue_id => parent.id)
132 assert_equal 7.5, @version.estimated_hours
133 end
134 end
107
135
108 test "should update all issue's fixed_version associations in case the hierarchy changed XXX" do
136 test "should update all issue's fixed_version associations in case the hierarchy changed XXX" do
109 User.current = User.find(1) # Need the admin's permissions
137 User.current = User.find(1) # Need the admin's permissions
General Comments 0
You need to be logged in to leave comments. Login now