From f8b3b195df93c0d3cfe4eca5df4ece1e561b6e3f Mon Sep 17 00:00:00 2001 From: kosiakkatrina <54268893+kosiakkatrina@users.noreply.github.com> Date: Wed, 8 Feb 2023 15:03:40 +0000 Subject: [PATCH] CLDC-1941 Only add existing location and scheme fields to the export (#1279) * Only add location and scheme fields to the export if the location and scheme exists * Add supported housing as one of the logs in export tests --- app/services/exports/lettings_log_export_service.rb | 4 ++-- spec/services/exports/lettings_log_export_service_spec.rb | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/services/exports/lettings_log_export_service.rb b/app/services/exports/lettings_log_export_service.rb index 1819670b8..12fe2bfb4 100644 --- a/app/services/exports/lettings_log_export_service.rb +++ b/app/services/exports/lettings_log_export_service.rb @@ -198,8 +198,8 @@ module Exports attribute_hash["sheltered"] = lettings_log.sheltered attribute_hash["nocharge"] = lettings_log.household_charge == 1 ? 1 : nil attribute_hash["chcharge"] = lettings_log.chcharge - add_scheme_fields!(lettings_log.scheme, attribute_hash) - add_location_fields!(lettings_log.location, attribute_hash) + add_scheme_fields!(lettings_log.scheme, attribute_hash) if lettings_log.scheme + add_location_fields!(lettings_log.location, attribute_hash) if lettings_log.location attribute_hash.delete("unittype_gn") end attribute_hash diff --git a/spec/services/exports/lettings_log_export_service_spec.rb b/spec/services/exports/lettings_log_export_service_spec.rb index eb8ef281f..bd7afb656 100644 --- a/spec/services/exports/lettings_log_export_service_spec.rb +++ b/spec/services/exports/lettings_log_export_service_spec.rb @@ -127,7 +127,7 @@ RSpec.describe Exports::LettingsLogExportService do context "and multiple lettings logs are available for export on same quarter" do before do - FactoryBot.create(:lettings_log, startdate: Time.zone.local(2022, 2, 1)) + FactoryBot.create(:lettings_log, startdate: Time.zone.local(2022, 2, 1), needstype: 2) FactoryBot.create(:lettings_log, startdate: Time.zone.local(2022, 3, 20)) end