Updated Deliverable.progress
* Make it return 100 if there are no issues * Get rid of sum in favor of manually adding values * Expand the progress bar to 100% #1136
This commit is contained in:
@@ -17,9 +17,11 @@ class Deliverable < ActiveRecord::Base
|
||||
|
||||
# TODO LATER: Shouldn't require the default_done_ratio patch
|
||||
def progress
|
||||
total = self.issues.sum(&:estimated_hours)
|
||||
balance = 0.0
|
||||
return 100 unless self.issues.count > 0
|
||||
|
||||
total = self.issues.collect(&:estimated_hours).inject {|sum, n| sum + n}
|
||||
balance = 0.0
|
||||
|
||||
self.issues.each do |issue|
|
||||
balance += issue.status.default_done_ratio * issue.estimated_hours
|
||||
end
|
||||
|
||||
@@ -5,5 +5,5 @@
|
||||
<%= content_tag(:td, number_to_currency(deliverable.budget)) %>
|
||||
<%= content_tag(:td, number_to_currency(deliverable.spent)) %>
|
||||
<%= content_tag(:td, format_date(deliverable.due_date)) %>
|
||||
<%= content_tag(:td, progress_bar(deliverable.progress, :width => '80px')) %>
|
||||
<%= content_tag(:td, progress_bar(deliverable.progress, :width => '100%')) %>
|
||||
</tr>
|
||||
|
||||
@@ -141,13 +141,15 @@ describe Deliverable, '.progress' do
|
||||
@issue4.should_receive(:status).and_return(@status_complete)
|
||||
@issue4.should_receive(:estimated_hours).twice.and_return(1.0)
|
||||
@issues = [@issue1, @issue2, @issue3, @issue4]
|
||||
@issues.stub!(:count).and_return(4)
|
||||
|
||||
@deliverable = Deliverable.new({ :subject => 'test' })
|
||||
@deliverable.should_receive(:issues).twice.and_return(@issues)
|
||||
@deliverable.should_receive(:issues).exactly(3).times.and_return(@issues)
|
||||
|
||||
@deliverable.progress.should eql(66)
|
||||
end
|
||||
|
||||
it 'should return 100 if there are no assigned issues'
|
||||
it 'should not change when hours are clocked'
|
||||
it 'should change if issues are assigned'
|
||||
it 'should change if issues are unassigned'
|
||||
|
||||
Reference in New Issue
Block a user