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

This commit is contained in:
Eric Davis
2010-10-21 09:50:46 -07:00
parent 1fafe8ea92
commit a302c17b04
3 changed files with 24 additions and 7 deletions
@@ -38,6 +38,9 @@ module RedmineContracts
# @option options [String] :deliverable_manager the id or login of the user
# to use for the deliverables manager
# 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={})
@contract_rate = options[:contract_rate] ? options[:contract_rate].to_f : 150.0
@account_executive = if options[:account_executive].present?
@@ -47,7 +50,9 @@ module RedmineContracts
@deliverable_manager = if options[:deliverable_manager].present?
user = User.find_by_login(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)
@@ -91,7 +96,7 @@ module RedmineContracts
convert_overhead(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!
+1
View File
@@ -5,6 +5,7 @@ namespace :redmine_contracts do
options[:contract_rate] = ENV['contract_rate']
options[:account_executive] = ENV['account_executive']
options[:deliverable_manager] = ENV['deliverable_manager']
options[:append_object_notes] = ENV['append_object_notes']
RedmineContracts::BudgetPluginMigration.check_for_installed_budget_plugin
data = RedmineContracts::BudgetPluginMigration.export_data
@@ -174,12 +174,23 @@ class BudgetPluginMigrationTest < ActionController::IntegrationTest
end
should "append the YAML dump of the old object to the notes" do
RedmineContracts::BudgetPluginMigration.migrate(@data)
d = Deliverable.find_by_title("Deliverable One")
context "YAML dumping of the old object to notes" do
should "be appended by default" do
RedmineContracts::BudgetPluginMigration.migrate(@data)
d = Deliverable.find_by_title("Deliverable One")
assert_match /Converted data/, d.notes
assert_match /"profit"=>200.0/, d.notes
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
assert_match /Converted data/, d.notes
assert_match /"profit"=>200.0/, d.notes
end
context "converting Fixed Deliverables" do