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 {
|
|
|
|
is_expected.to include(link: "http://localhost:3000/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
|
|
|
|
let(:original_procedure) do
|
|
|
|
p = create(:procedure, :published)
|
|
|
|
p.types_de_piece_justificative.create(
|
|
|
|
libelle: "Vidéo de votre demande de subvention",
|
|
|
|
description: "Pour optimiser vos chances, soignez la chorégraphie et privilégiez le chant polyphonique",
|
|
|
|
lien_demarche: "https://www.dance-academy.gouv.fr",
|
|
|
|
order_place: 0
|
|
|
|
)
|
|
|
|
p
|
|
|
|
end
|
|
|
|
|
2019-02-26 16:57:04 +01:00
|
|
|
let(:procedure) { original_procedure.clone(original_procedure.administrateurs.first, false) }
|
2019-01-10 15:55:04 +01:00
|
|
|
|
|
|
|
let(:type_pj) { original_procedure.types_de_piece_justificative.first }
|
|
|
|
let(:migrated_type_champ) { procedure.types_de_champ.find_by(libelle: type_pj.libelle) }
|
|
|
|
|
|
|
|
subject { ProcedureSerializer.new(procedure).serializable_hash }
|
|
|
|
|
|
|
|
it "is exposed as a legacy type PJ" 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
|
|
|
|
}
|
|
|
|
]
|
|
|
|
)
|
|
|
|
end
|
2019-01-10 15:56:18 +01:00
|
|
|
|
|
|
|
it "is not exposed as a type de champ" do
|
|
|
|
expect(subject[:types_de_champ]).not_to include(a_hash_including(libelle: type_pj.libelle))
|
|
|
|
end
|
2019-01-10 15:55:04 +01:00
|
|
|
end
|
2018-10-22 19:22:51 +02:00
|
|
|
end
|