diff --git a/lib/redmine_contracts/budget_plugin_migration.rb b/lib/redmine_contracts/budget_plugin_migration.rb index 9970b2a..66c1d2c 100644 --- a/lib/redmine_contracts/budget_plugin_migration.rb +++ b/lib/redmine_contracts/budget_plugin_migration.rb @@ -36,6 +36,13 @@ module RedmineContracts deliverable.contract = contract deliverable.manager = project.users.first + case old_deliverable['type'] + when 'FixedDeliverable' + deliverable.total = old_deliverable['fixed_cost'] + else + # no-op + end + deliverable.save! end end diff --git a/test/integration/budget_plugin_migration_test.rb b/test/integration/budget_plugin_migration_test.rb index 604385b..1893345 100644 --- a/test/integration/budget_plugin_migration_test.rb +++ b/test/integration/budget_plugin_migration_test.rb @@ -58,6 +58,15 @@ class BudgetPluginMigrationTest < ActionController::IntegrationTest assert_equal [@manager, @manager, @manager], Deliverable.all.collect(&:manager) end + + context "converting Fixed Deliverables" do + should "convert fixed_cost to total" do + RedmineContracts::BudgetPluginMigration.migrate(@data) + + d = FixedDeliverable.find_by_title("Version 1.0") + assert_equal 30_000, d.total + end + end end end