diff --git a/app/services/exports/lettings_log_export_service.rb b/app/services/exports/lettings_log_export_service.rb index 12fe2bfb4..6cc5c1f52 100644 --- a/app/services/exports/lettings_log_export_service.rb +++ b/app/services/exports/lettings_log_export_service.rb @@ -266,7 +266,7 @@ module Exports form << doc.create_element(key, value) end end - form << doc.create_element("providertype", lettings_log.owning_organisation.read_attribute_before_type_cast(:provider_type)) + form << doc.create_element("providertype", lettings_log.owning_organisation&.read_attribute_before_type_cast(:provider_type)) end xml_doc_to_temp_file(doc) diff --git a/spec/services/exports/lettings_log_export_service_spec.rb b/spec/services/exports/lettings_log_export_service_spec.rb index bd7afb656..a8d626b98 100644 --- a/spec/services/exports/lettings_log_export_service_spec.rb +++ b/spec/services/exports/lettings_log_export_service_spec.rb @@ -128,7 +128,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), needstype: 2) - FactoryBot.create(:lettings_log, startdate: Time.zone.local(2022, 3, 20)) + FactoryBot.create(:lettings_log, startdate: Time.zone.local(2022, 3, 20), owning_organisation: nil) end it "generates an XML manifest file with the expected content within the ZIP file" do