From 3c15a5315b56bf04d02e64b02e39c19fabf20392 Mon Sep 17 00:00:00 2001
From: Manny Dinssa <44172848+Dinssa@users.noreply.github.com>
Date: Mon, 13 Jan 2025 10:55:18 +0000
Subject: [PATCH] Export active to CDS as false for merged orgs
---
.../exports/organisation_export_service.rb | 1 +
.../organisation_export_service_spec.rb | 19 +++++++++++++++++++
2 files changed, 20 insertions(+)
diff --git a/app/services/exports/organisation_export_service.rb b/app/services/exports/organisation_export_service.rb
index afcf16cb0..fb034ac03 100644
--- a/app/services/exports/organisation_export_service.rb
+++ b/app/services/exports/organisation_export_service.rb
@@ -65,6 +65,7 @@ module Exports
attribute_hash["available_from"] = organisation.available_from&.iso8601
attribute_hash["profit_status"] = nil # will need update when we add the field to the org
attribute_hash["group"] = nil # will need update when we add the field to the org
+ attribute_hash["active"] = organisation.status == :active
attribute_hash
end
diff --git a/spec/services/exports/organisation_export_service_spec.rb b/spec/services/exports/organisation_export_service_spec.rb
index 199ee239e..d23d16e10 100644
--- a/spec/services/exports/organisation_export_service_spec.rb
+++ b/spec/services/exports/organisation_export_service_spec.rb
@@ -84,6 +84,25 @@ RSpec.describe Exports::OrganisationExportService do
it "returns the list with correct archive" do
expect(export_service.export_xml_organisations).to eq({ expected_zip_filename.gsub(".zip", "") => start_time })
end
+
+ context "and the organisation is merged" do
+ before do
+ organisation.update!(merge_date: Time.zone.yesterday)
+ end
+
+ it "generates an XML export file with the expected content within the ZIP file" do
+ expected_content = replace_entity_ids(organisation, xml_export_file.read)
+ expected_content.sub!("true", "false")
+ expected_content.sub!("", "#{organisation.merge_date.iso8601}")
+ 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_organisations
+ end
+ end
end
context "and multiple organisations are available for export" do