demarches-normaliennes/spec/views/shared/dossiers/_demande.html.haml_spec.rb
Pierre de La Morinerie 7ba76c6658 dossier: add a notice when some attachments of the dossier were lost
On the 22/01/2020, a technical error on the demarches-simplifees.fr
instance made us delete some files attached to some dossiers.

This PR adds a warning when browsing a dossier containing attachments
that were deleted.
2020-02-12 11:49:33 +01:00

64 lines
2.2 KiB
Ruby

describe 'shared/dossiers/demande.html.haml', type: :view do
let(:current_instructeur) { create(:instructeur) }
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
sign_in(current_instructeur.user)
end
subject { render 'shared/dossiers/demande.html.haml', dossier: dossier, demande_seen_at: nil, profile: 'usager' }
context 'when dossier was created by an etablissement' do
let(:etablissement) { create(:etablissement) }
it 'renders the etablissement infos' do
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)
end
context 'and entreprise is an association' do
let(:etablissement) { create(:etablissement, :is_association) }
it 'renders the association infos' do
expect(subject).to include(etablissement.association_rna)
expect(subject).to include(etablissement.association_titre)
expect(subject).to include(etablissement.association_objet)
end
end
end
context 'when dossier was created by an individual' do
let(:individual) { create(:individual) }
it 'renders the individual identity infos' do
expect(subject).to include(individual.gender)
expect(subject).to include(individual.nom)
expect(subject).to include(individual.prenom)
expect(subject).to include(I18n.l(individual.birthdate))
end
end
context 'when the dossier has champs' do
let(:procedure) { create(:procedure, :published, :with_type_de_champ) }
it 'renders the champs' do
dossier.champs.each do |champ|
expect(subject).to include(champ.libelle)
end
end
context 'when the dossier lost some attachments' do
before do
expect(view).to receive(:has_lost_attachments).and_return(true)
end
it 'displays a warning message' do
expect(subject).to include('Des pièces jointes de votre dossier peuvent être manquantes.')
end
end
end
end