From 30172b4be1dca78adbdeaafc7d03ad0856adf54d Mon Sep 17 00:00:00 2001 From: Eric Davis Date: Tue, 13 Jul 2010 14:35:23 -0700 Subject: [PATCH] [#4184] Starting on the budget data migration. --- .../budget_plugin_migration.rb | 18 ++++++ .../budget_plugin_migration/budget.yml | 55 +++++++++++++++++++ .../budget_plugin_migration_test.rb | 24 ++++++++ 3 files changed, 97 insertions(+) create mode 100644 lib/redmine_contracts/budget_plugin_migration.rb create mode 100644 test/fixtures/budget_plugin_migration/budget.yml create mode 100644 test/integration/budget_plugin_migration_test.rb diff --git a/lib/redmine_contracts/budget_plugin_migration.rb b/lib/redmine_contracts/budget_plugin_migration.rb new file mode 100644 index 0000000..95b9595 --- /dev/null +++ b/lib/redmine_contracts/budget_plugin_migration.rb @@ -0,0 +1,18 @@ +module RedmineContracts + + # TODO: decide how this is activated. + # Have the user dump yaml themselves? Or rename the tables and + # SQL select the data out into yaml? + # Deliverable.all.collect {|d| d.attributes}.to_yaml + class BudgetPluginMigration + @@data = nil + + def self.migrate(old_data) + @@data = old_data + end + + def self.data + @@data + end + end +end diff --git a/test/fixtures/budget_plugin_migration/budget.yml b/test/fixtures/budget_plugin_migration/budget.yml new file mode 100644 index 0000000..5bb71a3 --- /dev/null +++ b/test/fixtures/budget_plugin_migration/budget.yml @@ -0,0 +1,55 @@ +--- +- total_hours: 100.0 + overhead: 200.0 + profit_percent: + project_id: 1 + fixed_cost: + cost_per_hour: 50.0 + subject: Deliverable One + materials: 200.0 + id: 1 + type: HourlyDeliverable + project_manager_signoff: false + profit: 200.0 + overhead_percent: + description: "" + materials_percent: + due: 2008-06-30 + budget: 5600.0 + client_signoff: false +- total_hours: 12.0 + overhead: + profit_percent: 50 + project_id: 2 + fixed_cost: + cost_per_hour: 25.0 + subject: Deliverable 2 + materials: 0.0 + id: 2 + type: HourlyDeliverable + project_manager_signoff: false + profit: + overhead_percent: 150 + description: "" + materials_percent: + due: 2008-06-18 + budget: 900.0 + client_signoff: false +- total_hours: 80.0 + overhead: + profit_percent: 150 + project_id: 2 + fixed_cost: 30000.0 + cost_per_hour: 85.0 + subject: Version 1.0 + materials: 0.0 + id: 3 + type: FixedDeliverable + project_manager_signoff: true + profit: + overhead_percent: 60 + description: Some description here + materials_percent: + due: 2008-05-01 + budget: 93000.0 + client_signoff: true diff --git a/test/integration/budget_plugin_migration_test.rb b/test/integration/budget_plugin_migration_test.rb new file mode 100644 index 0000000..833a8a9 --- /dev/null +++ b/test/integration/budget_plugin_migration_test.rb @@ -0,0 +1,24 @@ +require 'test_helper' + +class BudgetPluginMigrationTest < ActionController::IntegrationTest + def setup + configure_overhead_plugin + end + + def load_test_fixture + YAML.load(File.read(File.expand_path(File.dirname(__FILE__)) + "/../fixtures/budget_plugin_migration/budget.yml")) + end + + context "migrate" do + should "load a YAML dump of the old budget data" do + @data = load_test_fixture + RedmineContracts::BudgetPluginMigration.migrate(@data) + + assert RedmineContracts::BudgetPluginMigration.data + end + + should "create a new Deliverable for each old Deliverable" + should "create a new Contract for each project that had an old deliverable" + end +end +