diff --git a/lib/redmine_contracts/budget_plugin_migration.rb b/lib/redmine_contracts/budget_plugin_migration.rb index 6f5f995..b9c22d0 100644 --- a/lib/redmine_contracts/budget_plugin_migration.rb +++ b/lib/redmine_contracts/budget_plugin_migration.rb @@ -140,15 +140,15 @@ module RedmineContracts total ||= 0 if old_deliverable['materials'].present? && old_deliverable['materials'] > 0.0 - deliverable.overhead_budgets << OverheadBudget.new(:deliverable => deliverable, - :budget => old_deliverable['materials'], - :hours => 0) + deliverable.fixed_budgets << FixedBudget.new(:deliverable => deliverable, + :budget => old_deliverable['materials'], + :markup => 0) elsif old_deliverable['materials_percent'].present? && old_deliverable['materials_percent'] > 0.0 materials = total * (old_deliverable['materials_percent'].to_f / 100) - deliverable.overhead_budgets << OverheadBudget.new(:deliverable => deliverable, - :budget => materials, - :hours => 0) + deliverable.fixed_budgets << FixedBudget.new(:deliverable => deliverable, + :budget => materials, + :markup => 0) end end diff --git a/test/integration/budget_plugin_migration_test.rb b/test/integration/budget_plugin_migration_test.rb index 86a9112..22d93ca 100644 --- a/test/integration/budget_plugin_migration_test.rb +++ b/test/integration/budget_plugin_migration_test.rb @@ -85,13 +85,13 @@ class BudgetPluginMigrationTest < ActionController::IntegrationTest end should "create a new Overhead Budget record for any overhead" do - assert_difference("OverheadBudget.count", 5) do + assert_difference("OverheadBudget.count", 3) do RedmineContracts::BudgetPluginMigration.migrate(@data) end d = Deliverable.find_by_title("Deliverable One") - assert_equal 2, d.overhead_budgets.count - assert_equal 400, d.overhead_budget_total + assert_equal 1, d.overhead_budgets.count + assert_equal 200, d.overhead_budget_total overhead = d.overhead_budgets.first assert overhead @@ -100,12 +100,12 @@ class BudgetPluginMigrationTest < ActionController::IntegrationTest end should "create a new Overhead Budget record for any overhead percent" do - assert_difference("OverheadBudget.count", 5) do + assert_difference("OverheadBudget.count", 3) do RedmineContracts::BudgetPluginMigration.migrate(@data) end d = Deliverable.find_by_title("Deliverable 2") - assert_equal 2, d.overhead_budgets.count + assert_equal 1, d.overhead_budgets.count overhead = d.overhead_budgets.first assert overhead @@ -114,32 +114,27 @@ class BudgetPluginMigrationTest < ActionController::IntegrationTest end - should "create a new Overhead Budget record for any materials" do - assert_difference("OverheadBudget.count", 5) do + should "create a new Fixed Budget record for any materials" do + assert_difference("FixedBudget.count", 2) do RedmineContracts::BudgetPluginMigration.migrate(@data) end d = Deliverable.find_by_title("Deliverable One") - assert_equal 2, d.overhead_budgets.count - assert_equal 400, d.overhead_budget_total - - materials = d.overhead_budgets.last - assert materials - assert_equal 200, materials.budget - assert_equal 0, materials.hours + assert_equal 1, d.fixed_budgets.count + assert_equal 200, d.fixed_budget_total end - should "create a new Overhead Budget record for any materials percent" do - assert_difference("OverheadBudget.count", 5) do + should "create a new Fixed Budget record for any materials percent" do + assert_difference("FixedBudget.count", 2) do RedmineContracts::BudgetPluginMigration.migrate(@data) end d = Deliverable.find_by_title("Deliverable 2") - assert_equal 2, d.overhead_budgets.count - materials = d.overhead_budgets.last + assert_equal 1, d.fixed_budgets.count + materials = d.fixed_budgets.first assert materials assert_equal 12 * 25 * 0.1, materials.budget - assert_equal 0, materials.hours + assert_equal 0, materials.markup.to_i end