diff --git a/app/services/exports/organisation_export_service.rb b/app/services/exports/organisation_export_service.rb index 2b2da71c8..afcf16cb0 100644 --- a/app/services/exports/organisation_export_service.rb +++ b/app/services/exports/organisation_export_service.rb @@ -56,11 +56,13 @@ module Exports def apply_cds_transformation(organisation) attribute_hash = organisation.attributes - attribute_hash["deleted_at"] = organisation.discarded_at + attribute_hash["deleted_at"] = organisation.discarded_at&.iso8601 attribute_hash["dsa_signed"] = organisation.data_protection_confirmed? - attribute_hash["dsa_signed_at"] = organisation.data_protection_confirmation&.signed_at + attribute_hash["dsa_signed_at"] = organisation.data_protection_confirmation&.signed_at&.iso8601 attribute_hash["dpo_email"] = organisation.data_protection_confirmation&.data_protection_officer_email attribute_hash["provider_type"] = organisation.provider_type_before_type_cast + attribute_hash["merge_date"] = organisation.merge_date&.iso8601 + 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 diff --git a/app/services/exports/user_export_service.rb b/app/services/exports/user_export_service.rb index aaa30c424..707d13c14 100644 --- a/app/services/exports/user_export_service.rb +++ b/app/services/exports/user_export_service.rb @@ -60,6 +60,7 @@ module Exports attribute_hash["organisation_name"] = user.organisation.name attribute_hash["active"] = user.active? attribute_hash["phone"] = [user.phone, user.phone_extension].compact.join(" ") + attribute_hash["last_sign_in_at"] = user.last_sign_in_at&.iso8601 attribute_hash end end diff --git a/spec/fixtures/exports/user.xml b/spec/fixtures/exports/user.xml index d29a33225..4c5286c68 100644 --- a/spec/fixtures/exports/user.xml +++ b/spec/fixtures/exports/user.xml @@ -6,7 +6,7 @@ Danny Rojas {organisation_id} 5 - + 2022-03-03T00:00:00+00:00 data_provider 1234512345123 123 false diff --git a/spec/services/exports/organisation_export_service_spec.rb b/spec/services/exports/organisation_export_service_spec.rb index 51c8fe8cf..199ee239e 100644 --- a/spec/services/exports/organisation_export_service_spec.rb +++ b/spec/services/exports/organisation_export_service_spec.rb @@ -17,7 +17,7 @@ RSpec.describe Exports::OrganisationExportService do def replace_entity_ids(organisation, export_template) export_template.sub!(/\{id\}/, organisation["id"].to_s) export_template.sub!(/\{name\}/, organisation["name"]) - export_template.sub!(/\{dsa_signed_at\}/, organisation.data_protection_confirmation&.signed_at.to_s) + export_template.sub!(/\{dsa_signed_at\}/, organisation.data_protection_confirmation&.signed_at&.iso8601) export_template.sub!(/\{dpo_email\}/, organisation.data_protection_confirmation&.data_protection_officer_email) end diff --git a/spec/services/exports/user_export_service_spec.rb b/spec/services/exports/user_export_service_spec.rb index 854dd1ce7..3f4ece76d 100644 --- a/spec/services/exports/user_export_service_spec.rb +++ b/spec/services/exports/user_export_service_spec.rb @@ -43,7 +43,7 @@ RSpec.describe Exports::UserExportService do end context "and one user is available for export" do - let!(:user) { create(:user, organisation:, name: "Danny Rojas", phone_extension: "123") } + let!(:user) { create(:user, organisation:, name: "Danny Rojas", phone_extension: "123", last_sign_in_at: Time.zone.local(2022, 3, 3)) } it "generates a ZIP export file with the expected filename" do expect(storage_service).to receive(:write_file).with(expected_zip_filename, any_args)