@@ -52,8 +52,9 class Version < ActiveRecord::Base | |||
|
52 | 52 | end |
|
53 | 53 | |
|
54 | 54 | # Returns the total estimated time for this version |
|
55 | # (sum of leaves estimated_hours) | |
|
55 | 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 | 58 | end |
|
58 | 59 | |
|
59 | 60 | # Returns the total reported time for this version |
@@ -105,6 +105,34 class VersionTest < ActiveSupport::TestCase | |||
|
105 | 105 | assert_progress_equal 25.0/100.0*100, v.closed_pourcent |
|
106 | 106 | end |
|
107 | 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 | |
|
135 | ||
|
108 | 136 | test "should update all issue's fixed_version associations in case the hierarchy changed XXX" do |
|
109 | 137 | User.current = User.find(1) # Need the admin's permissions |
|
110 | 138 |
General Comments 0
You need to be logged in to leave comments.
Login now