Feature #37862 » 0002-Adds-estimated-remaining-time-to-version-page-37862-.patch
| app/models/version.rb | ||
|---|---|---|
| 24 | 24 |
@estimated_hours ||= sum(:estimated_hours).to_f |
| 25 | 25 |
end |
| 26 | 26 | |
| 27 |
# Returns the total estimated remaining time for this version |
|
| 28 |
# (sum of leaves remaining_estimated_hours) |
|
| 29 |
def estimated_remaining_hours |
|
| 30 |
@estimated_remaining_hours ||= sum(IssueQuery::ESTIMATED_REMAINING_HOURS_SQL).to_f |
|
| 31 |
end |
|
| 32 | ||
| 27 | 33 |
# Returns the total amount of open issues for this version. |
| 28 | 34 |
def open_count |
| 29 | 35 |
load_counts |
| ... | ... | |
| 236 | 242 |
fixed_issues.estimated_hours |
| 237 | 243 |
end |
| 238 | 244 | |
| 245 |
# Returns the total estimated remaining time for this version |
|
| 246 |
# (sum of leaves estimated_remaining_hours) |
|
| 247 |
def estimated_remaining_hours |
|
| 248 |
@remaining_hours ||= fixed_issues.estimated_remaining_hours |
|
| 249 |
end |
|
| 250 | ||
| 239 | 251 |
# Returns the total reported time for this version |
| 240 | 252 |
def spent_hours |
| 241 | 253 |
@spent_hours ||= TimeEntry.joins(:issue).where("#{Issue.table_name}.fixed_version_id = ?", id).sum(:hours).to_f
|
| app/views/versions/show.html.erb | ||
|---|---|---|
| 22 | 22 |
<td class="total-hours"><%= link_to html_hours(l_hours(@version.visible_fixed_issues.estimated_hours)), |
| 23 | 23 |
project_issues_path(@version.project, :set_filter => 1, :status_id => '*', :fixed_version_id => @version.id, :c => [:tracker, :status, :subject, :estimated_hours], :t => [:estimated_hours]) %></td> |
| 24 | 24 |
</tr> |
| 25 |
<tr> |
|
| 26 |
<th><%= l(:field_estimated_remaining_hours) %></th> |
|
| 27 |
<td class="total-hours"> |
|
| 28 |
<%= link_to html_hours(l_hours(@version.visible_fixed_issues.estimated_remaining_hours)), |
|
| 29 |
project_issues_path(@version.project, :set_filter => 1, :status_id => '*', :fixed_version_id => @version.id, :c => [:tracker, :status, :subject, :estimated_remaining_hours], :t => [:estimated_remaining_hours]) %> |
|
| 30 |
</td> |
|
| 31 |
</tr> |
|
| 25 | 32 |
<% if User.current.allowed_to_view_all_time_entries?(@project) %> |
| 26 | 33 |
<tr> |
| 27 | 34 |
<th><%= l(:label_spent_time) %></th> |
| test/unit/version_test.rb | ||
|---|---|---|
| 201 | 201 |
assert_equal false, version.behind_schedule? |
| 202 | 202 |
end |
| 203 | 203 | |
| 204 |
test "#estimated_hours should return 0 with no assigned issues" do |
|
| 204 |
test "#estimated_hours and estimated_remaining_hours should return 0 with no assigned issues" do
|
|
| 205 | 205 |
version = Version.generate! |
| 206 | 206 |
assert_equal 0, version.estimated_hours |
| 207 |
assert_equal 0, version.estimated_remaining_hours |
|
| 207 | 208 |
end |
| 208 | 209 | |
| 209 |
test "#estimated_hours should return 0 with no estimated hours" do |
|
| 210 |
test "#estimated_hours and estimated_remaining_hours should return 0 with no estimated hours" do
|
|
| 210 | 211 |
version = Version.create!(:project_id => 1, :name => 'test') |
| 211 | 212 |
add_issue(version) |
| 212 | 213 |
assert_equal 0, version.estimated_hours |
| 214 |
assert_equal 0, version.estimated_remaining_hours |
|
| 213 | 215 |
end |
| 214 | 216 | |
| 215 |
test "#estimated_hours should return return the sum of estimated hours" do
|
|
| 217 |
test "#estimated_hours and estimated_remaining_hours should return the sum of estimated hours and estimated remaining hours" do
|
|
| 216 | 218 |
version = Version.create!(:project_id => 1, :name => 'test') |
| 217 |
add_issue(version, :estimated_hours => 2.5) |
|
| 218 |
add_issue(version, :estimated_hours => 5) |
|
| 219 |
add_issue(version, :estimated_hours => 2.5, :done_ratio => 90)
|
|
| 220 |
add_issue(version, :estimated_hours => 5, :done_ratio => 50)
|
|
| 219 | 221 |
assert_equal 7.5, version.estimated_hours |
| 222 |
assert_equal 2.75, version.estimated_remaining_hours |
|
| 220 | 223 |
end |
| 221 | 224 | |
| 222 |
test "#estimated_hours should return the sum of leaves estimated hours" do
|
|
| 225 |
test "#estimated_hours and remaining_hours should return the sum of leaves estimated hours and estimated remaining hours" do
|
|
| 223 | 226 |
version = Version.create!(:project_id => 1, :name => 'test') |
| 224 | 227 |
parent = add_issue(version) |
| 225 |
add_issue(version, :estimated_hours => 2.5, :parent_issue_id => parent.id) |
|
| 226 |
add_issue(version, :estimated_hours => 5, :parent_issue_id => parent.id) |
|
| 228 |
add_issue(version, :estimated_hours => 2.5, :done_ratio => 90, :parent_issue_id => parent.id)
|
|
| 229 |
add_issue(version, :estimated_hours => 5, :done_ratio => 50, :parent_issue_id => parent.id)
|
|
| 227 | 230 |
assert_equal 7.5, version.estimated_hours |
| 231 |
assert_equal 2.75, version.estimated_remaining_hours |
|
| 228 | 232 |
end |
| 229 | 233 | |
| 230 | 234 |
test "should update all issue's fixed_version associations in case the hierarchy changed XXX" do |
- « Previous
- 1
- …
- 3
- 4
- 5
- Next »