|
|
|
|
@ -150,6 +150,32 @@ RSpec.describe Exports::LettingsLogExportService do
|
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "and one lettings log with unknown user details is available for export" do |
|
|
|
|
let!(:lettings_log) { FactoryBot.create(:lettings_log, :completed, details_known_2: 1, created_by: user, propcode: "123", ppostcode_full: "SE2 6RT", postcode_full: "NW1 5TY", tenancycode: "BZ737", startdate: Time.zone.local(2022, 2, 2, 10, 36, 49), voiddate: Time.zone.local(2019, 11, 3), mrcdate: Time.zone.local(2020, 5, 5, 10, 36, 49), tenancylength: 5, underoccupation_benefitcap: 4) } |
|
|
|
|
|
|
|
|
|
def replace_person_details(export_file) |
|
|
|
|
export_file.sub!("<age2>32</age2>", "<age2>-9</age2>") |
|
|
|
|
export_file.sub!("<ecstat2>6</ecstat2>", "<ecstat2>10</ecstat2>") |
|
|
|
|
export_file.sub!("<sex2>M</sex2>", "<sex2>R</sex2>") |
|
|
|
|
export_file.sub!("<relat2>P</relat2>", "<relat2>R</relat2>") |
|
|
|
|
export_file.sub!("<refused>0</refused>", "<refused>1</refused>") |
|
|
|
|
export_file.sub!("<hhtype>4</hhtype>", "<hhtype>3</hhtype>") |
|
|
|
|
export_file.sub!("<totadult>2</totadult>", "<totadult>1</totadult>") |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it "generates an XML export file with the expected content within the ZIP file" do |
|
|
|
|
expected_content = replace_entity_ids(lettings_log, xml_export_file.read) |
|
|
|
|
expected_content = replace_person_details(expected_content) |
|
|
|
|
expect(storage_service).to receive(:write_file).with(expected_zip_filename, any_args) do |_, content| |
|
|
|
|
entry = Zip::File.open_buffer(content).find_entry(expected_data_filename) |
|
|
|
|
expect(entry).not_to be_nil |
|
|
|
|
expect(entry.get_input_stream.read).to eq(expected_content) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
export_service.export_xml_lettings_logs |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "with 23/24 collection period" do |
|
|
|
|
before do |
|
|
|
|
Timecop.freeze(Time.zone.local(2023, 4, 3)) |
|
|
|
|
|