Browse Source

Export dates as iso8601 (#2871)

pull/2873/head
kosiakkatrina 2 months ago committed by GitHub
parent
commit
9a164dfa68
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 6
      app/services/exports/organisation_export_service.rb
  2. 1
      app/services/exports/user_export_service.rb
  3. 2
      spec/fixtures/exports/user.xml
  4. 2
      spec/services/exports/organisation_export_service_spec.rb
  5. 2
      spec/services/exports/user_export_service_spec.rb

6
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

1
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

2
spec/fixtures/exports/user.xml vendored

@ -6,7 +6,7 @@
<name>Danny Rojas</name>
<organisation_id>{organisation_id}</organisation_id>
<sign_in_count>5</sign_in_count>
<last_sign_in_at/>
<last_sign_in_at>2022-03-03T00:00:00+00:00</last_sign_in_at>
<role>data_provider</role>
<phone>1234512345123 123</phone>
<is_dpo>false</is_dpo>

2
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

2
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)

Loading…
Cancel
Save