[#4183] Updated HourlyDeliverable#total to calculate the estimated total

This commit is contained in:
Eric Davis
2010-07-07 16:00:40 -07:00
parent 26aac777e4
commit 91b16a2310
4 changed files with 42 additions and 5 deletions
@@ -108,7 +108,6 @@ class DeliverablesNewTest < ActionController::IntegrationTest
assert_equal '2010-01-01', @deliverable.start_date.to_s
assert_equal '2010-12-31', @deliverable.end_date.to_s
assert_equal @manager, @deliverable.manager
assert_equal nil, @deliverable.total
end
+31 -2
View File
@@ -1,12 +1,41 @@
require File.dirname(__FILE__) + '/../test_helper'
class HourlyDeliverableTest < ActiveSupport::TestCase
context "#total" do
should "be 0 when not assigned to a contract" do
assert_equal 0, HourlyDeliverable.new.total
end
should "be 0 with no billable rate set on the Contract" do
contract = Contract.generate!(:billable_rate => nil)
d = HourlyDeliverable.generate!(:contract => contract)
assert_equal 0, d.total
end
should "be 0 with no budgets" do
contract = Contract.generate!(:billable_rate => 100.0)
d = HourlyDeliverable.generate!(:contract => contract)
assert_equal 0, d.total
end
should "multiply the total number of budgeted hours by the contract billable rate" do
contract = Contract.generate!(:billable_rate => 100.0)
d = HourlyDeliverable.generate!(:contract => contract)
d.labor_budgets << LaborBudget.generate!(:hours => 10)
d.overhead_budgets << OverheadBudget.generate!(:hours => 20)
assert_equal 100.0 * 30, d.total
end
end
context "#total=" do
should "not write any attributes" do
d = HourlyDeliverable.new
d.total = '$100.00'
assert_equal nil, d.total
assert_equal nil, d.read_attribute(:total)
end
end
@@ -16,7 +45,7 @@ class HourlyDeliverableTest < ActiveSupport::TestCase
d.write_attribute(:total, 100.00)
d.clear_total
assert_equal nil, d.total
assert_equal nil, d.read_attribute(:total)
end
end