Calc cleanup
This commit is contained in:
@@ -186,6 +186,18 @@ describe Budget, '.progress' do
|
||||
@budget = Budget.new(@project.id)
|
||||
@budget.progress.should eql(100)
|
||||
end
|
||||
|
||||
it 'should return 100 if there is no budget' do
|
||||
@deliverable1 = mock_model(Deliverable, :project_id => @project, :budget => 0.00, :progress => 50)
|
||||
@deliverable2 = mock_model(Deliverable, :project_id => @project, :budget => 0.00, :progress => 75)
|
||||
|
||||
@project = mock_model(Project)
|
||||
Deliverable.stub!(:find_all_by_project_id).and_return([@deliverable1, @deliverable2])
|
||||
Project.stub!(:find).with(@project.id).and_return(@project)
|
||||
|
||||
@budget = Budget.new(@project.id)
|
||||
@budget.progress.should eql(100)
|
||||
end
|
||||
end
|
||||
|
||||
describe Budget,'.budget' do
|
||||
|
||||
@@ -113,7 +113,7 @@ end
|
||||
describe Deliverable, '.budget_ratio' do
|
||||
it 'should be the whole number of the budget spent' do
|
||||
@deliverable = Deliverable.new({ :subject => 'test' })
|
||||
@deliverable.should_receive(:budget).and_return(3000.00)
|
||||
@deliverable.should_receive(:budget).exactly(3).times.and_return(3000.00)
|
||||
@deliverable.should_receive(:spent).and_return(1000.00)
|
||||
|
||||
@deliverable.budget_ratio.should eql(33)
|
||||
|
||||
@@ -15,3 +15,10 @@ describe FixedDeliverable, '.spent' do
|
||||
@deliverable.spent.should eql(2500.0)
|
||||
end
|
||||
end
|
||||
|
||||
describe FixedDeliverable, '.profit as a %' do
|
||||
it 'should return the % of the fixed bid amount' do
|
||||
@deliverable = FixedDeliverable.new({ :subject => 'test', :profit_percent => 50, :fixed_cost => 1000.0 })
|
||||
@deliverable.profit.should eql(500.0)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -26,3 +26,10 @@ describe HourlyDeliverable, '.spent' do
|
||||
@deliverable.spent.should eql(60.0)
|
||||
end
|
||||
end
|
||||
|
||||
describe HourlyDeliverable, '.profit as a %' do
|
||||
it 'should return the % of the hours mutipled by the cost per hour amount' do
|
||||
@deliverable = HourlyDeliverable.new({ :subject => 'test', :profit_percent => 50, :cost_per_hour => 100.0, :total_hours => 10 })
|
||||
@deliverable.profit.should eql(500.0)
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user