Browse Source

Set case log ID offset at export (#562)

pull/564/head
baarkerlounger 3 years ago committed by GitHub
parent
commit
f1f6c2123e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      app/services/exports/case_log_export_service.rb
  2. 2
      spec/services/exports/case_log_export_service_spec.rb

3
app/services/exports/case_log_export_service.rb

@ -18,6 +18,8 @@ module Exports
field_name.starts_with?("details_known_") || pattern_age.match(field_name) || omitted_attrs.include?(field_name) ? true : false
end
LOG_ID_OFFSET = 300_000_000_000
private
def save_export_run
@ -71,6 +73,7 @@ module Exports
next
else
value = case_log.read_attribute_before_type_cast(key)
value += LOG_ID_OFFSET if key == "id"
form << doc.create_element(key, value)
end
end

2
spec/services/exports/case_log_export_service_spec.rb

@ -13,7 +13,7 @@ RSpec.describe Exports::CaseLogExportService do
let(:case_log) { FactoryBot.create(:case_log, :completed) }
def replace_entity_ids(export_template)
export_template.sub!(/\{id\}/, case_log["id"].to_s)
export_template.sub!(/\{id\}/, (case_log["id"] + Exports::CaseLogExportService::LOG_ID_OFFSET).to_s)
export_template.sub!(/\{owning_org_id\}/, case_log["owning_organisation_id"].to_s)
export_template.sub!(/\{managing_org_id\}/, case_log["managing_organisation_id"].to_s)
export_template.sub!(/\{created_by_id\}/, case_log["created_by_id"].to_s)

Loading…
Cancel
Save