[#4184] Converted Labor Budget for HourlyDeliverables.

This commit is contained in:
Eric Davis
2010-07-14 10:30:40 -07:00
parent 70d57ee359
commit e6ab8ac3ab
2 changed files with 33 additions and 0 deletions
@@ -41,6 +41,12 @@ module RedmineContracts
@total = deliverable.total = old_deliverable['fixed_cost']
when 'HourlyDeliverable'
@total = old_deliverable['total_hours'].to_f * old_deliverable['cost_per_hour'].to_f
if old_deliverable['total_hours'].present? || old_deliverable['cost_per_hour'].present?
deliverable.labor_budgets << LaborBudget.new(:deliverable => deliverable,
:budget => @total,
:hours => old_deliverable['total_hours'])
end
else
@total = 0
end
@@ -98,6 +98,33 @@ class BudgetPluginMigrationTest < ActionController::IntegrationTest
assert_equal 30_000, d.total
end
end
context "converting Hourly Deliverables" do
should "create a new Labor Budget" do
assert_difference("LaborBudget.count", 2) do
RedmineContracts::BudgetPluginMigration.migrate(@data)
end
d1 = Deliverable.find_by_title("Deliverable One")
assert_equal 1, d1.labor_budgets.count
assert_equal 100.0 * 50.0, d1.labor_budget_total
labor1 = d1.labor_budgets.first
assert labor1
assert_equal 5000, labor1.budget
assert_equal 100, labor1.hours
d2 = Deliverable.find_by_title("Deliverable 2")
assert_equal 1, d2.labor_budgets.count
assert_equal 12 * 25, d2.labor_budget_total
labor1 = d2.labor_budgets.first
assert labor1
assert_equal 300, labor1.budget
assert_equal 12, labor1.hours
end
end
end
end