tech(review): add a guard clause to prevent missing pdf, enhance specs

This commit is contained in:
mfo 2024-04-02 09:53:11 +02:00
parent 2944a0c2c3
commit 3a895fbd4a
No known key found for this signature in database
GPG key ID: 7CE3E1F5B794A8EC
3 changed files with 59 additions and 32 deletions

View file

@ -23,37 +23,6 @@ describe 'instructeurs/dossiers/show', type: :view do
expect(subject).to have_text('en construction')
end
context 'with a motivation' do
let(:dossier) { create :dossier, :accepte, :with_motivation }
it 'displays the motivation text' do
expect(subject).to have_content(dossier.motivation)
end
end
context 'with an attestation' do
let(:dossier) { create :dossier, :accepte, :with_attestation }
it 'provides a link to the attestation' do
pdf = dossier.attestation.pdf
expect(dossier).to receive(:attestation).and_return(double(pdf: pdf)).at_least(2)
expect(subject).to have_text('Attestation')
expect(subject).to have_text("Télécharger lattestation")
end
end
context 'with a justificatif' do
let(:dossier) do
dossier = create(:dossier, :accepte, :with_justificatif)
dossier.justificatif_motivation.blob.update(virus_scan_result: ActiveStorage::VirusScanner::SAFE)
dossier
end
it 'allows to download the justificatif' do
expect(subject).to have_css("a[href*='/rails/active_storage/blobs/']", text: dossier.justificatif_motivation.attachment.filename.to_s)
end
end
context 'en_construction' do
let(:dossier) { create(:dossier, :en_construction) }
it 'displays the correct actions' do