Added a conversation test for the Billing plugin. #1922
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
class RateConversion
|
||||
MemberRateDataFile = "#{RAILS_ROOT}/tmp/budget_member_rate_data.yml"
|
||||
DeliverableDataFile = "#{RAILS_ROOT}/tmp/budget_deliverable_data.yml"
|
||||
VendorInvoiceDataFile = "#{RAILS_ROOT}/tmp/billing_vendor_invoice_data.yml"
|
||||
|
||||
|
||||
def self.compare_values(pre, post, message)
|
||||
puts "ERROR: #{message} (pre: #{pre}, post: #{post})" unless pre == post
|
||||
|
||||
+74
-1
@@ -77,8 +77,81 @@ namespace :rate_plugin do
|
||||
if counter > 0
|
||||
puts "#{counter} errors found."
|
||||
else
|
||||
puts "No conversation errors found, congrats."
|
||||
puts "No Budget conversation errors found, congrats."
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
namespace :billing do
|
||||
desc "Export the values of the Billing plugin to a file before installing the rate plugin"
|
||||
task :pre_install_export => :environment do
|
||||
|
||||
unless Redmine::Plugin.registered_plugins[:redmine_billing].version == "0.0.1"
|
||||
puts "ERROR: This task is only needed when upgrading from version 0.0.1 to version 0.3.0"
|
||||
return false
|
||||
end
|
||||
|
||||
invoices = ''
|
||||
|
||||
FixedVendorInvoice.find(:all).each do |invoice|
|
||||
invoices << {
|
||||
:id => invoice.id,
|
||||
:number => invoice.number,
|
||||
:amount => invoice.amount,
|
||||
:project_id => invoice.project_id,
|
||||
:type => 'FixedVendorInvoice'
|
||||
}.to_yaml
|
||||
end
|
||||
|
||||
HourlyVendorInvoice.find(:all).each do |invoice|
|
||||
invoices << {
|
||||
:id => invoice.id,
|
||||
:number => invoice.number,
|
||||
:amount => invoice.amount_for_user,
|
||||
:project_id => invoice.project_id,
|
||||
:type => 'HourlyVendorInvoice'
|
||||
}.to_yaml
|
||||
end
|
||||
|
||||
File.open(RateConversion::VendorInvoiceDataFile, 'w') do |file|
|
||||
file.puts invoices
|
||||
end
|
||||
end
|
||||
|
||||
desc "Check the values of the export"
|
||||
task :post_install_check => :environment do
|
||||
|
||||
unless Redmine::Plugin.registered_plugins[:redmine_billing].version == "0.3.0"
|
||||
puts "ERROR: Please upgrade the billing_plugin to 0.3.0 now"
|
||||
return false
|
||||
end
|
||||
|
||||
counter = 0
|
||||
|
||||
File.open(RateConversion::VendorInvoiceDataFile) do |file|
|
||||
YAML::load_documents(file) { |invoice_export|
|
||||
invoice = VendorInvoice.find_by_id(invoice_export[:id])
|
||||
|
||||
if invoice.nil?
|
||||
puts "ERROR: No VendorInvoice found with the ID of #{invoice_export[:id]}"
|
||||
counter += 1
|
||||
else
|
||||
if invoice.type.to_s == "FixedVendorInvoice"
|
||||
counter += 1 unless RateConversion.compare_values(invoice_export[:amount], invoice.amount, "VendorInvoice #{invoice.id}'s amount is off")
|
||||
else
|
||||
counter += 1 unless RateConversion.compare_values(invoice_export[:amount], invoice.amount_for_user, "VendorInvoice #{invoice.id}'s amount is off")
|
||||
end
|
||||
|
||||
end
|
||||
}
|
||||
end
|
||||
|
||||
if counter > 0
|
||||
puts "#{counter} errors found."
|
||||
else
|
||||
puts "No Billing conversation errors found, congrats."
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user