Merge pull request #2931 from betagouv/fix_cgdd

Let the API return times in UTC for now
This commit is contained in:
LeSim 2018-10-31 11:51:16 +01:00 committed by GitHub
commit 3aef0f379b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 36 additions and 8 deletions

View file

@ -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

View file

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

View file

@ -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

View file

@ -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

View file

@ -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?

View file

@ -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