diff --git a/app/views/shared/attachment/_show.html.haml b/app/views/shared/attachment/_show.html.haml index 34b8c62e7..4437724a7 100644 --- a/app/views/shared/attachment/_show.html.haml +++ b/app/views/shared/attachment/_show.html.haml @@ -28,3 +28,9 @@ (virus détecté, merci d’envoyer un autre fichier) - else (virus détecté, le téléchargement de ce fichier est bloqué) + - elsif attachment.virus_scanner.corrupt? + - if user_can_upload + (le fichier est corrompu, merci d’envoyer un autre fichier) + - else + (le fichier est corrompu, le téléchargement est bloqué) + diff --git a/spec/views/shared/attachment/_show.html.haml_spec.rb b/spec/views/shared/attachment/_show.html.haml_spec.rb index faa00daf4..b9737c8c4 100644 --- a/spec/views/shared/attachment/_show.html.haml_spec.rb +++ b/spec/views/shared/attachment/_show.html.haml_spec.rb @@ -55,4 +55,14 @@ describe 'shared/attachment/_show.html.haml', type: :view do expect(subject).to have_text('virus détecté') end end + + context 'when the file is corrupted' do + let(:virus_scan_result) { ActiveStorage::VirusScanner::INTEGRITY_ERROR } + + it 'displays the filename, but doesn’t allow to download the file' do + expect(subject).to have_text(champ.piece_justificative_file.filename.to_s) + expect(subject).not_to have_link(champ.piece_justificative_file.filename.to_s) + expect(subject).to have_text('corrompu') + end + end end