diff --git a/app/serializers/commentaire_serializer.rb b/app/serializers/commentaire_serializer.rb index 19360bfdf..3cc79c8a2 100644 --- a/app/serializers/commentaire_serializer.rb +++ b/app/serializers/commentaire_serializer.rb @@ -4,6 +4,10 @@ class CommentaireSerializer < ActiveModel::Serializer :created_at, :attachment + def created_at + object.created_at&.in_time_zone('UTC') + end + def attachment object.file_url end diff --git a/app/serializers/dossier_serializer.rb b/app/serializers/dossier_serializer.rb index a35e5ba57..0acd0ed29 100644 --- a/app/serializers/dossier_serializer.rb +++ b/app/serializers/dossier_serializer.rb @@ -50,17 +50,29 @@ class DossierSerializer < ActiveModel::Serializer end def initiated_at - object.en_construction_at + object.en_construction_at&.in_time_zone('UTC') end def received_at - object.en_instruction_at + object.en_instruction_at&.in_time_zone('UTC') end def instructeurs object.followers_gestionnaires.pluck(:email) end + def created_at + object.created_at&.in_time_zone('UTC') + end + + def updated_at + object.updated_at&.in_time_zone('UTC') + end + + def processed_at + object.processed_at&.in_time_zone('UTC') + end + private def user_geometry(dossier) diff --git a/app/serializers/dossiers_serializer.rb b/app/serializers/dossiers_serializer.rb index a1c225229..6751e5c53 100644 --- a/app/serializers/dossiers_serializer.rb +++ b/app/serializers/dossiers_serializer.rb @@ -4,8 +4,12 @@ class DossiersSerializer < ActiveModel::Serializer :initiated_at, :state + def updated_at + object.updated_at&.in_time_zone('UTC') + end + def initiated_at - object.en_construction_at + object.en_construction_at&.in_time_zone('UTC') end def state diff --git a/app/serializers/piece_justificative_serializer.rb b/app/serializers/piece_justificative_serializer.rb index fdcf1d2c9..0a7a7a724 100644 --- a/app/serializers/piece_justificative_serializer.rb +++ b/app/serializers/piece_justificative_serializer.rb @@ -4,4 +4,8 @@ class PieceJustificativeSerializer < ActiveModel::Serializer :content_url has_one :user + + def created_at + object.created_at&.in_time_zone('UTC') + end end diff --git a/app/serializers/procedure_serializer.rb b/app/serializers/procedure_serializer.rb index bd5605a6c..d1a7a491c 100644 --- a/app/serializers/procedure_serializer.rb +++ b/app/serializers/procedure_serializer.rb @@ -18,6 +18,10 @@ class ProcedureSerializer < ActiveModel::Serializer has_many :types_de_champ_private, serializer: TypeDeChampSerializer has_many :types_de_piece_justificative, serializer: TypeDePieceJustificativeSerializer + def archived_at + object.archived_at&.in_time_zone('UTC') + end + def link if object.path.present? if object.brouillon_avec_lien? diff --git a/spec/controllers/api/v1/dossiers_controller_spec.rb b/spec/controllers/api/v1/dossiers_controller_spec.rb index 6873f031c..47ced3e71 100644 --- a/spec/controllers/api/v1/dossiers_controller_spec.rb +++ b/spec/controllers/api/v1/dossiers_controller_spec.rb @@ -75,8 +75,8 @@ describe API::V1::DossiersController do describe 'dossier' do subject { super().first } it { expect(subject[:id]).to eq(dossier.id) } - it { expect(subject[:updated_at]).to eq("2008-09-01T10:05:00.000+02:00") } - it { expect(subject[:initiated_at]).to eq("2008-09-01T10:06:00.000+02:00") } + it { expect(subject[:updated_at]).to eq("2008-09-01T08:05:00.000Z") } + it { expect(subject[:initiated_at]).to eq("2008-09-01T08:06:00.000Z") } it { expect(subject[:state]).to eq("initiated") } it { expect(subject.keys.size).to eq(4) } end @@ -148,8 +148,8 @@ describe API::V1::DossiersController do it { expect(subject[:id]).to eq(dossier.id) } it { expect(subject[:state]).to eq(dossier.state) } - it { expect(subject[:created_at]).to eq('2008-09-01T10:05:00.000+02:00') } - it { expect(subject[:updated_at]).to eq('2008-09-01T10:05:00.000+02:00') } + it { expect(subject[:created_at]).to eq('2008-09-01T08:05:00.000Z') } + it { expect(subject[:updated_at]).to eq('2008-09-01T08:05:00.000Z') } it { expect(subject[:archived]).to eq(dossier.archived) } it { expect(subject.keys).to match_array(field_list) } @@ -337,7 +337,7 @@ describe API::V1::DossiersController do it { expect(subject.size).to eq 2 } it { expect(subject.first[:body]).to eq 'plop' } - it { expect(subject.first[:created_at]).to eq '2016-03-14T14:00:00.000+01:00' } + it { expect(subject.first[:created_at]).to eq '2016-03-14T13:00:00.000Z' } it { expect(subject.first[:email]).to eq 'plop@plip.com' } end