[#4673] Add an option to remove the converted data from deliverables

This commit is contained in:
Eric Davis committed 2010-10-21 09:50:46 -07:00
1 parent 1fafe8ea92
commit a302c17b04
3 files changed
+19 -2

No files matched your search

@@ -38,6 +38,9 @@ module RedmineContracts
# @option options [String] :deliverable_manager the id or login of the user # @option options [String] :deliverable_manager the id or login of the user
# to use for the deliverables manager # to use for the deliverables manager
# Defaults to the first user on the project. # Defaults to the first user on the project.
# @option options [boolean] :append_object_notes show the old Budget data be
# added to the Deliverable notes (for debugging)
# Defaults to true (will append)
def self.migrate(old_data, options={}) def self.migrate(old_data, options={})
@contract_rate = options[:contract_rate] ? options[:contract_rate].to_f : 150.0 @contract_rate = options[:contract_rate] ? options[:contract_rate].to_f : 150.0
@account_executive = if options[:account_executive].present? @account_executive = if options[:account_executive].present?
@@ -49,6 +52,8 @@ module RedmineContracts
user ||= User.find_by_id(options[:deliverable_manager]) user ||= User.find_by_id(options[:deliverable_manager])
end end
@append_object_notes = options[:append_object_notes].nil? ? true : options[:append_object_notes]
@@data = YAML.load(old_data) @@data = YAML.load(old_data)
# Map old deliverable ids to the new ones # Map old deliverable ids to the new ones
@@ -91,7 +96,7 @@ module RedmineContracts
convert_overhead(deliverable, old_deliverable, @total_cost) convert_overhead(deliverable, old_deliverable, @total_cost)
convert_materials(deliverable, old_deliverable, @total_cost) convert_materials(deliverable, old_deliverable, @total_cost)
append_old_deliverable_to_notes(old_deliverable, deliverable) append_old_deliverable_to_notes(old_deliverable, deliverable) if @append_object_notes
deliverable.save! deliverable.save!
+1
View File
@@ -5,6 +5,7 @@ namespace :redmine_contracts do
options[:contract_rate] = ENV['contract_rate'] options[:contract_rate] = ENV['contract_rate']
options[:account_executive] = ENV['account_executive'] options[:account_executive] = ENV['account_executive']
options[:deliverable_manager] = ENV['deliverable_manager'] options[:deliverable_manager] = ENV['deliverable_manager']
options[:append_object_notes] = ENV['append_object_notes']
RedmineContracts::BudgetPluginMigration.check_for_installed_budget_plugin RedmineContracts::BudgetPluginMigration.check_for_installed_budget_plugin
data = RedmineContracts::BudgetPluginMigration.export_data data = RedmineContracts::BudgetPluginMigration.export_data
@@ -174,7 +174,8 @@ class BudgetPluginMigrationTest < ActionController::IntegrationTest
end end
should "append the YAML dump of the old object to the notes" do context "YAML dumping of the old object to notes" do
should "be appended by default" do
RedmineContracts::BudgetPluginMigration.migrate(@data) RedmineContracts::BudgetPluginMigration.migrate(@data)
d = Deliverable.find_by_title("Deliverable One") d = Deliverable.find_by_title("Deliverable One")
@@ -182,6 +183,16 @@ class BudgetPluginMigrationTest < ActionController::IntegrationTest
assert_match /"profit"=>200.0/, d.notes assert_match /"profit"=>200.0/, d.notes
end end
should "be have an option to be turned off" do
RedmineContracts::BudgetPluginMigration.migrate(@data, :append_object_notes => false)
d = Deliverable.find_by_title("Deliverable One")
assert_equal nil, d.notes.match(/Converted data/)
assert_equal nil, d.notes.match(/"profit"=>200.0/)
end
end
context "converting Fixed Deliverables" do context "converting Fixed Deliverables" do
should "convert the budget field to total" do should "convert the budget field to total" do
RedmineContracts::BudgetPluginMigration.migrate(@data) RedmineContracts::BudgetPluginMigration.migrate(@data)