[#2180] Expose migrated types PJ as legacy type PJ in dossier API

This commit is contained in:
Frederic Merizen 2019-01-10 18:49:21 +01:00
parent bf23abdfe3
commit 63519f04c8
2 changed files with 15 additions and 0 deletions

View file

@ -52,6 +52,11 @@ class DossierSerializer < ActiveModel::Serializer
PiecesJustificativesService.serialize_champs_as_pjs(object)
end
def types_de_piece_justificative
ActiveModelSerializers::SerializableResource.new(object.types_de_piece_justificative).serializable_hash +
PiecesJustificativesService.serialize_types_de_champ_as_type_pj(object)
end
def email
object.user&.email
end

View file

@ -65,6 +65,7 @@ describe DossierSerializer do
end
let(:type_pj) { original_procedure.types_de_piece_justificative.first }
let(:migrated_type_champ) { procedure.types_de_champ.find_by(libelle: type_pj.libelle) }
let(:dossier) { create(:dossier, procedure: procedure) }
let(:champ_pj) { dossier.champs.last }
@ -76,6 +77,15 @@ describe DossierSerializer do
it "exposes the PJ in the legacy format" do
is_expected.to include(
types_de_piece_justificative: [
{
"id" => type_pj.id,
"libelle" => type_pj.libelle,
"description" => type_pj.description,
"lien_demarche" => type_pj.lien_demarche,
"order_place" => type_pj.order_place
}
],
pieces_justificatives: [
{
"content_url" => champ_pj.for_api,