demarches-normaliennes/spec/serializers/procedure_serializer_spec.rb
2020-09-02 11:26:26 +02:00

43 lines
1.6 KiB
Ruby
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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}")
is_expected.to include(state: "publiee")
}
end
context 'when a type PJ was cloned to a type champ PJ' do
let(:original_pj_id) { 3 }
let(:cloned_type_de_champ) do
build(:type_de_champ_piece_justificative,
libelle: "Vidéo de votre demande de subvention",
description: "Pour optimiser vos chances, soignez la chorégraphie et privilégiez le chant polyphonique.\r\nRécupérer le formulaire vierge pour mon dossier : https://www.dance-academy.gouv.fr",
old_pj: { stable_id: original_pj_id },
position: 0)
end
let(:procedure) { create(:procedure, :published, types_de_champ: [cloned_type_de_champ]) }
subject { ProcedureSerializer.new(procedure).serializable_hash }
it "is exposed as a legacy type PJ" do
is_expected.to include(
types_de_piece_justificative: [
{
"id" => original_pj_id,
"libelle" => cloned_type_de_champ.libelle,
"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" => cloned_type_de_champ.order_place
}
]
)
end
it "is not exposed as a type de champ" do
expect(subject[:types_de_champ]).to be_empty
end
end
end