2024-04-29 00:17:15 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2023-03-06 15:51:08 +01:00
|
|
|
describe 'shared/dossiers/demande', type: :view do
|
2019-08-06 11:02:54 +02:00
|
|
|
let(:current_instructeur) { create(:instructeur) }
|
2018-09-25 15:56:18 +02:00
|
|
|
let(:individual) { nil }
|
|
|
|
let(:etablissement) { nil }
|
|
|
|
let(:procedure) { create(:procedure, :published) }
|
|
|
|
let(:dossier) { create(:dossier, :en_construction, procedure: procedure, etablissement: etablissement, individual: individual) }
|
|
|
|
|
|
|
|
before do
|
2019-08-07 11:15:16 +02:00
|
|
|
sign_in(current_instructeur.user)
|
2018-09-25 15:56:18 +02:00
|
|
|
end
|
|
|
|
|
2023-03-06 15:51:08 +01:00
|
|
|
subject { render 'shared/dossiers/demande', dossier: dossier, demande_seen_at: nil, profile: 'usager' }
|
2018-09-25 15:56:18 +02:00
|
|
|
|
|
|
|
context 'when dossier was created by an etablissement' do
|
|
|
|
let(:etablissement) { create(:etablissement) }
|
|
|
|
|
|
|
|
it 'renders the etablissement infos' do
|
2020-01-27 14:28:23 +01:00
|
|
|
expect(subject).to include(etablissement.entreprise_raison_sociale)
|
|
|
|
expect(subject).to include(etablissement.entreprise_siret_siege_social)
|
|
|
|
expect(subject).to include(etablissement.entreprise_forme_juridique)
|
2018-09-25 15:56:18 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'and entreprise is an association' do
|
|
|
|
let(:etablissement) { create(:etablissement, :is_association) }
|
|
|
|
|
|
|
|
it 'renders the association infos' do
|
2020-01-27 14:28:23 +01:00
|
|
|
expect(subject).to include(etablissement.association_rna)
|
|
|
|
expect(subject).to include(etablissement.association_titre)
|
|
|
|
expect(subject).to include(etablissement.association_objet)
|
2018-09-25 15:56:18 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when dossier was created by an individual' do
|
2021-11-19 13:48:52 +01:00
|
|
|
let(:individual) { build(:individual) }
|
2018-09-25 15:56:18 +02:00
|
|
|
|
|
|
|
it 'renders the individual identity infos' do
|
2020-01-27 14:28:23 +01:00
|
|
|
expect(subject).to include(individual.gender)
|
|
|
|
expect(subject).to include(individual.nom)
|
|
|
|
expect(subject).to include(individual.prenom)
|
2020-08-31 13:47:27 +02:00
|
|
|
expect(subject).to include(I18n.l(individual.birthdate, format: :long))
|
2018-09-25 15:56:18 +02:00
|
|
|
end
|
|
|
|
end
|
2018-09-25 15:56:49 +02:00
|
|
|
|
|
|
|
context 'when the dossier has champs' do
|
|
|
|
let(:procedure) { create(:procedure, :published, :with_type_de_champ) }
|
|
|
|
|
|
|
|
it 'renders the champs' do
|
2022-11-10 22:21:14 +01:00
|
|
|
dossier.champs_public.each do |champ|
|
2020-01-27 14:28:23 +01:00
|
|
|
expect(subject).to include(champ.libelle)
|
|
|
|
end
|
|
|
|
end
|
2018-09-25 15:56:49 +02:00
|
|
|
end
|
2024-03-18 21:22:14 +01:00
|
|
|
|
|
|
|
context 'when a champ is freshly build' do
|
|
|
|
let(:procedure) { create(:procedure, :published, :with_type_de_champ) }
|
|
|
|
before do
|
|
|
|
dossier.champs_public.first.destroy
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'renders without error' do
|
|
|
|
procedure.active_revision.types_de_champ.each do |tdc|
|
|
|
|
expect(subject).to include(tdc.libelle)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2018-09-25 15:56:18 +02:00
|
|
|
end
|