[#4182] Added an OverheadBudget to track a Deliverable's overhead.

This commit is contained in:
Eric Davis
2010-07-07 10:38:58 -07:00
parent fdd49642b2
commit b22db284c5
9 changed files with 105 additions and 7 deletions
+13 -2
View File
@@ -60,8 +60,15 @@ class DeliverablesEditTest < ActionController::IntegrationTest
check "Feature Sign Off"
check "Warranty Sign Off"
fill_in "hrs", :with => '20'
fill_in "$", :with => '$2,000'
within("#deliverable-labor") do
fill_in "hrs", :with => '20'
fill_in "$", :with => '$2,000'
end
within("#deliverable-overhead") do
fill_in "hrs", :with => '10'
fill_in "$", :with => '$1,000'
end
click_button "Save"
@@ -78,5 +85,9 @@ class DeliverablesEditTest < ActionController::IntegrationTest
assert_equal 20, @labor_budget.hours
assert_equal 2000.0, @labor_budget.budget
assert_equal 1, @hourly_deliverable.overhead_budgets.count
@overhead_budget = @hourly_deliverable.overhead_budgets.first
assert_equal 10, @overhead_budget.hours
assert_equal 1000.0, @overhead_budget.budget
end
end
+17 -4
View File
@@ -112,7 +112,7 @@ class DeliverablesNewTest < ActionController::IntegrationTest
end
should "create new budget item for the deliverables" do
should "create new budget items for the deliverables" do
@manager = User.generate!
@role = Role.generate!
User.add_to_project(@manager, @project, @role)
@@ -128,19 +128,32 @@ class DeliverablesNewTest < ActionController::IntegrationTest
fill_in "End Date", :with => '2010-12-31'
fill_in "Notes", :with => 'Some notes on the deliverable'
fill_in "hrs", :with => '20'
fill_in "$", :with => '$2,000'
within("#deliverable-labor") do
fill_in "hrs", :with => '20'
fill_in "$", :with => '$2,000'
end
within("#deliverable-overhead") do
fill_in "hrs", :with => '10'
fill_in "$", :with => '$1,000'
end
click_button "Save"
assert_response :success
assert_template 'contracts/show'
@deliverable = Deliverable.last
assert_equal 1, @deliverable.labor_budgets.count
@labor_budget = @deliverable.labor_budgets.first
assert_equal 20, @labor_budget.hours
assert_equal 2000.0, @labor_budget.budget
assert_equal 1, @deliverable.overhead_budgets.count
@overhead_budget = @deliverable.overhead_budgets.first
assert_equal 10, @overhead_budget.hours
assert_equal 1000.0, @overhead_budget.budget
end
end
+1
View File
@@ -4,6 +4,7 @@ class DeliverableTest < ActiveSupport::TestCase
should_belong_to :contract
should_belong_to :manager
should_have_many :labor_budgets
should_have_many :overhead_budgets
should_validate_presence_of :title
should_validate_presence_of :type
+29
View File
@@ -0,0 +1,29 @@
require File.dirname(__FILE__) + '/../test_helper'
class OverheadBudgetTest < ActiveSupport::TestCase
should_belong_to :deliverable
context "#budget=" do
should "strip dollar signs when writing" do
e = OverheadBudget.new
e.budget = '$100.00'
assert_equal 100.00, e.budget.to_f
end
should "strip commas when writing" do
e = OverheadBudget.new
e.budget = '20,100.00'
assert_equal 20100.00, e.budget.to_f
end
should "strip spaces when writing" do
e = OverheadBudget.new
e.budget = '20 100.00'
assert_equal 20100.00, e.budget.to_f
end
end
end