From ad0a74ea7c08847f05e008118afd5aea72d0d084 Mon Sep 17 00:00:00 2001 From: Paul Chavard Date: Thu, 4 Jul 2019 15:02:25 +0200 Subject: [PATCH] Fix dates in dossiers export --- app/models/dossier.rb | 4 ++-- spec/services/procedure_export_v2_service_spec.rb | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/app/models/dossier.rb b/app/models/dossier.rb index 021f750d9..df3133982 100644 --- a/app/models/dossier.rb +++ b/app/models/dossier.rb @@ -445,8 +445,8 @@ class Dossier < ApplicationRecord ['Archivé', :archived], ['État du dossier', I18n.t(state, scope: [:activerecord, :attributes, :dossier, :state])], ['Dernière mise à jour le', :updated_at], - ['Passé en construction le', :en_instruction_at], - ['Passé en instruction le', :en_construction_at], + ['Passé en construction le', :en_construction_at], + ['Passé en instruction le', :en_instruction_at], ['Traité le', :processed_at], ['Motivation de la décision', :motivation], ['Instructeurs', followers_gestionnaires.map(&:email).join(' ')] diff --git a/spec/services/procedure_export_v2_service_spec.rb b/spec/services/procedure_export_v2_service_spec.rb index 16b8a92c9..6c88afc94 100644 --- a/spec/services/procedure_export_v2_service_spec.rb +++ b/spec/services/procedure_export_v2_service_spec.rb @@ -80,6 +80,13 @@ describe ProcedureExportV2Service do it 'should have data' do expect(dossiers_sheet.data.size).to eq(1) expect(etablissements_sheet.data.size).to eq(1) + + # SimpleXlsxReader is transforming datetimes in utc... It is only used in test so we just hack around. + offset = dossier.en_construction_at.utc_offset + en_construction_at = Time.zone.at(dossiers_sheet.data[0][9] - offset.seconds) + en_instruction_at = Time.zone.at(dossiers_sheet.data[0][10] - offset.seconds) + expect(en_construction_at).to eq(dossier.en_construction_at.round) + expect(en_instruction_at).to eq(dossier.en_instruction_at.round) end end