[fix #2777] DossiersSerializer: add state

This commit is contained in:
simon lehericey 2018-10-08 17:56:18 +02:00
parent 87e731bc75
commit 2288303de9
3 changed files with 9 additions and 2 deletions

View file

@ -1,9 +1,14 @@
class DossiersSerializer < ActiveModel::Serializer
attributes :id,
:updated_at,
:initiated_at
:initiated_at,
:state
def initiated_at
object.en_construction_at
end
def state
object.old_state_value
end
end

View file

@ -77,7 +77,8 @@ describe API::V1::DossiersController do
it { expect(subject[:id]).to eq(dossier.id) }
it { expect(subject[:updated_at]).to eq("2008-09-01T10:05:00.000Z") }
it { expect(subject[:initiated_at]).to eq("2008-09-01T10:06:00.000Z") }
it { expect(subject.keys.size).to eq(3) }
it { expect(subject[:state]).to eq("initiated") }
it { expect(subject.keys.size).to eq(4) }
end
end

View file

@ -6,6 +6,7 @@ describe DossiersSerializer do
let(:dossier) { create(:dossier, :en_construction) }
it { is_expected.to include(initiated_at: dossier.en_construction_at) }
it { is_expected.to include(state: 'initiated') }
end
end
end