Browse Source

CLDC-3835: Export merged organisations as inactive (#2896)

* Export active to CDS as false for merged orgs

* Export status to CDS for orgs
pull/2888/merge v0.4.94
Manny Dinssa 5 days ago committed by GitHub
parent
commit
02a77e0889
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 3
      app/services/exports/organisation_export_constants.rb
  2. 2
      app/services/exports/organisation_export_service.rb
  3. 1
      spec/fixtures/exports/organisation.xml
  4. 21
      spec/services/exports/organisation_export_service_spec.rb

3
app/services/exports/organisation_export_constants.rb

@ -22,6 +22,7 @@ module Exports::OrganisationExportConstants
"dsa_signed_at",
"dpo_email",
"profit_status",
"group"
"group",
"status"
]
end

2
app/services/exports/organisation_export_service.rb

@ -65,6 +65,8 @@ 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["status"] = organisation.status
attribute_hash["active"] = attribute_hash["status"] == :active
attribute_hash
end

1
spec/fixtures/exports/organisation.xml vendored

@ -22,5 +22,6 @@
<dpo_email>{dpo_email}</dpo_email>
<profit_status/>
<group/>
<status>active</status>
</form>
</forms>

21
spec/services/exports/organisation_export_service_spec.rb

@ -84,6 +84,27 @@ 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
let(:expected_content) { replace_entity_ids(organisation, xml_export_file.read) }
before do
organisation.update!(merge_date: Time.zone.yesterday)
expected_content.sub!("<active>true</active>", "<active>false</active>")
expected_content.sub!("<merge_date/>", "<merge_date>#{organisation.merge_date.iso8601}</merge_date>")
expected_content.sub!("<status>active</status>", "<status>merged</status>")
end
it "generates an XML export file with the expected content within the ZIP file" do
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

Loading…
Cancel
Save