Add initiated_at to DossiersSerializer
This commit is contained in:
parent
1ff7dfe264
commit
5eff915b9d
4 changed files with 12 additions and 5 deletions
|
@ -1,4 +1,5 @@
|
|||
class DossiersSerializer < ActiveModel::Serializer
|
||||
attributes :id,
|
||||
:updated_at
|
||||
:updated_at,
|
||||
:initiated_at
|
||||
end
|
||||
|
|
|
@ -13,7 +13,8 @@
|
|||
{
|
||||
"id": 2,
|
||||
"nom_projet": "Demande de subvention dans le cadre d'accompagnement d'enfant à l'étranger",
|
||||
"updated_at": "2008-09-01T08:05:00.000Z"
|
||||
"updated_at": "2008-09-01T08:05:00.000Z",
|
||||
"initiated_at": "2008-09-02T08:05:00.000Z"
|
||||
}
|
||||
],
|
||||
"pagination": {
|
||||
|
|
|
@ -25,7 +25,7 @@ describe API::V1::DossiersController do
|
|||
context 'when procedure is found and belongs to admin' do
|
||||
let(:procedure_id) { procedure.id }
|
||||
let(:date_creation) { Time.utc(2008, 9, 1, 10, 5, 0) }
|
||||
let!(:dossier) { Timecop.freeze(date_creation) { create(:dossier, :with_entreprise, procedure: procedure, state: 'initiated') } }
|
||||
let!(:dossier) { Timecop.freeze(date_creation) { create(:dossier, :with_entreprise, :initiated, procedure: procedure) } }
|
||||
let(:body) { JSON.parse(retour.body, symbolize_names: true) }
|
||||
|
||||
it 'return REST code 200', :show_in_doc do
|
||||
|
@ -53,7 +53,8 @@ describe API::V1::DossiersController do
|
|||
subject { super().first }
|
||||
it { expect(subject[:id]).to eq(dossier.id) }
|
||||
it { expect(subject[:updated_at]).to eq("2008-09-01T10:05:00.000Z") }
|
||||
it { expect(subject.keys.size).to eq(2) }
|
||||
it { expect(subject[:initiated_at]).to eq("2008-09-01T10:06:00.000Z") }
|
||||
it { expect(subject.keys.size).to eq(3) }
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -73,7 +73,11 @@ FactoryGirl.define do
|
|||
end
|
||||
|
||||
trait :initiated do
|
||||
state 'initiated'
|
||||
after(:create) do |dossier, _evaluator|
|
||||
dossier.state = 'initiated'
|
||||
dossier.initiated_at = dossier.created_at + 1.minute
|
||||
dossier.save!
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue