demarches-normaliennes/spec/serializers/procedure_serializer_spec.rb

44 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://test.host/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
{
type: :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 }
}
end
let(:procedure) { create(:procedure, :published, types_de_champ_public: [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" => 0
}
]
)
end
it "is not exposed as a type de champ" do
expect(subject[:types_de_champ]).to be_empty
end
end
end