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:
1 parent
dee52c0042
commit
7e9e2759b8
3 files changed
+8
-4
No files matched your search
@@ -17,9 +17,11 @@ class Deliverable < ActiveRecord::Base
|
|||||||
|
|
||||||
# TODO LATER: Shouldn't require the default_done_ratio patch
|
# TODO LATER: Shouldn't require the default_done_ratio patch
|
||||||
def progress
|
def progress
|
||||||
total = self.issues.sum(&:estimated_hours)
|
return 100 unless self.issues.count > 0
|
||||||
balance = 0.0
|
|
||||||
|
|
||||||
|
total = self.issues.collect(&:estimated_hours).inject {|sum, n| sum + n}
|
||||||
|
balance = 0.0
|
||||||
|
|
||||||
self.issues.each do |issue|
|
self.issues.each do |issue|
|
||||||
balance += issue.status.default_done_ratio * issue.estimated_hours
|
balance += issue.status.default_done_ratio * issue.estimated_hours
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -5,5 +5,5 @@
|
|||||||
<%= content_tag(:td, number_to_currency(deliverable.budget)) %>
|
<%= content_tag(:td, number_to_currency(deliverable.budget)) %>
|
||||||
<%= content_tag(:td, number_to_currency(deliverable.spent)) %>
|
<%= content_tag(:td, number_to_currency(deliverable.spent)) %>
|
||||||
<%= content_tag(:td, format_date(deliverable.due_date)) %>
|
<%= 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>
|
</tr>
|
||||||
@@ -141,13 +141,15 @@ describe Deliverable, '.progress' do
|
|||||||
@issue4.should_receive(:status).and_return(@status_complete)
|
@issue4.should_receive(:status).and_return(@status_complete)
|
||||||
@issue4.should_receive(:estimated_hours).twice.and_return(1.0)
|
@issue4.should_receive(:estimated_hours).twice.and_return(1.0)
|
||||||
@issues = [@issue1, @issue2, @issue3, @issue4]
|
@issues = [@issue1, @issue2, @issue3, @issue4]
|
||||||
|
@issues.stub!(:count).and_return(4)
|
||||||
|
|
||||||
@deliverable = Deliverable.new({ :subject => 'test' })
|
@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)
|
@deliverable.progress.should eql(66)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'should return 100 if there are no assigned issues'
|
||||||
it 'should not change when hours are clocked'
|
it 'should not change when hours are clocked'
|
||||||
it 'should change if issues are assigned'
|
it 'should change if issues are assigned'
|
||||||
it 'should change if issues are unassigned'
|
it 'should change if issues are unassigned'
|
||||||
|
|||||||
Reference in new issue
Block a user