Browse Source

Remove nils before adding up location units (#1290)

webinar-demo
kosiakkatrina 2 years ago committed by GitHub
parent
commit
0ff387ad84
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      app/services/exports/lettings_log_export_service.rb
  2. 4
      spec/services/exports/lettings_log_export_service_spec.rb

2
app/services/exports/lettings_log_export_service.rb

@ -214,7 +214,7 @@ module Exports
attribute_hash["reghome"] = scheme.registered_under_care_act_before_type_cast
attribute_hash["schtype"] = scheme.scheme_type_before_type_cast
attribute_hash["support"] = scheme.support_type_before_type_cast
attribute_hash["units_scheme"] = scheme.locations.map(&:units).sum
attribute_hash["units_scheme"] = scheme.locations.map(&:units).compact.sum
end
def add_location_fields!(location, attribute_hash)

4
spec/services/exports/lettings_log_export_service_spec.rb

@ -258,6 +258,10 @@ RSpec.describe Exports::LettingsLogExportService do
let(:lettings_log) { FactoryBot.create(:lettings_log, :completed, :export, :sh, scheme:, location:, created_by: user, owning_organisation: organisation, startdate: Time.utc(2022, 2, 2, 10, 36, 49), underoccupation_benefitcap: 4, sheltered: 1) }
before do
FactoryBot.create(:location, scheme:, startdate: Time.zone.local(2021, 4, 1), units: nil)
end
it "generates an XML export file with the expected content" do
expected_content = replace_entity_ids(lettings_log, export_file.read)
expect(storage_service).to receive(:write_file).with(expected_zip_filename, any_args) do |_, content|

Loading…
Cancel
Save