2018-10-22 19:22:51 +02:00
describe ProcedureSerializer do
describe '#attributes' do
subject { ProcedureSerializer . new ( procedure ) . serializable_hash }
let ( :procedure ) { create ( :procedure , :published ) }
it {
2024-03-27 09:06:42 +01:00
is_expected . to include ( link : " http://test.host/commencer/ #{ procedure . path } " )
2018-10-22 19:23:30 +02:00
is_expected . to include ( state : " publiee " )
2018-10-22 19:22:51 +02:00
}
end
2019-01-10 15:55:04 +01:00
context 'when a type PJ was cloned to a type champ PJ' do
2019-07-25 16:49:06 +02:00
let ( :original_pj_id ) { 3 }
let ( :cloned_type_de_champ ) do
2022-08-04 11:39:07 +02:00
{
type : :piece_justificative ,
2019-01-10 15:55:04 +01:00
libelle : " Vidéo de votre demande de subvention " ,
2019-07-25 16:49:06 +02:00
description : " Pour optimiser vos chances, soignez la chorégraphie et privilégiez le chant polyphonique. \r \n Récupérer le formulaire vierge pour mon dossier : https://www.dance-academy.gouv.fr " ,
2022-08-04 11:39:07 +02:00
old_pj : { stable_id : original_pj_id }
}
2019-01-10 15:55:04 +01:00
end
2022-08-04 11:39:07 +02:00
let ( :procedure ) { create ( :procedure , :published , types_de_champ_public : [ cloned_type_de_champ ] ) }
2019-01-10 15:55:04 +01:00
subject { ProcedureSerializer . new ( procedure ) . serializable_hash }
it " is exposed as a legacy type PJ " do
is_expected . to include (
types_de_piece_justificative : [
{
2019-07-25 16:49:06 +02:00
" id " = > original_pj_id ,
2022-08-04 11:39:07 +02:00
" libelle " = > cloned_type_de_champ [ :libelle ] ,
2019-07-25 16:49:06 +02:00
" description " = > 'Pour optimiser vos chances, soignez la chorégraphie et privilégiez le chant polyphonique.' ,
" lien_demarche " = > 'https://www.dance-academy.gouv.fr' ,
2022-05-25 09:51:40 +02:00
" order_place " = > 0
2019-01-10 15:55:04 +01:00
}
]
)
end
2019-01-10 15:56:18 +01:00
it " is not exposed as a type de champ " do
2019-07-25 16:49:06 +02:00
expect ( subject [ :types_de_champ ] ) . to be_empty
2019-01-10 15:56:18 +01:00
end
2019-01-10 15:55:04 +01:00
end
2018-10-22 19:22:51 +02:00
end