[#4673] Add an option to remove the converted data from deliverables
This commit is contained in:
1 parent
1fafe8ea92
commit
a302c17b04
3 files changed
+24
-7
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?
|
||||||
@@ -47,7 +50,9 @@ module RedmineContracts
|
|||||||
@deliverable_manager = if options[:deliverable_manager].present?
|
@deliverable_manager = if options[:deliverable_manager].present?
|
||||||
user = User.find_by_login(options[:deliverable_manager])
|
user = User.find_by_login(options[:deliverable_manager])
|
||||||
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)
|
||||||
|
|
||||||
@@ -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!
|
||||||
|
|
||||||
|
|||||||
@@ -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,12 +174,23 @@ 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
|
||||||
RedmineContracts::BudgetPluginMigration.migrate(@data)
|
should "be appended by default" do
|
||||||
d = Deliverable.find_by_title("Deliverable One")
|
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
|
end
|
||||||
|
|
||||||
context "converting Fixed Deliverables" do
|
context "converting Fixed Deliverables" do
|
||||||
|
|||||||
Reference in new issue
Block a user