diff --git a/spec/features/instructeurs/instruction_spec.rb b/spec/features/instructeurs/instruction_spec.rb index 7a7c8fdd5..8d2862cb9 100644 --- a/spec/features/instructeurs/instruction_spec.rb +++ b/spec/features/instructeurs/instruction_spec.rb @@ -138,21 +138,21 @@ feature 'Instructing a dossier:' do expect(page).to have_text("Dossier envoyé") end - context 'A instructeur can download a zip of the attachments of a dossier', js: true do + context 'with dossiers having attached files', js: true do let(:procedure) { create(:procedure, :published, :with_piece_justificative, instructeurs: [instructeur]) } let(:dossier) { create(:dossier, :en_construction, procedure: procedure) } let(:champ) { dossier.champs.first } let(:path) { 'spec/fixtures/files/piece_justificative_0.pdf' } let(:commentaire) { create(:commentaire, instructeur: instructeur, dossier: dossier) } - before { + before do champ.piece_justificative_file.attach(io: File.open(path), filename: "piece_justificative_0.pdf", content_type: "application/pdf") log_in(instructeur.email, password) visit instructeur_dossier_path(procedure, dossier) - } + end - scenario 'it possible to open the zip file' do + scenario 'A instructeur can download an archive containing a single attachment' do find(:css, '.attached').click click_on 'Télécharger toutes les pièces jointes' # For some reason, clicking the download link does not trigger the download in the headless browser ; @@ -168,7 +168,7 @@ feature 'Instructing a dossier:' do expect(files[0].uncompressed_size).to be File.size(path) end - scenario 'it possible to open the zip file with multiple attachments' do + scenario 'A instructeur can download an archive containing several identical attachments' do commentaire.piece_jointe.attach(io: File.open(path), filename: "piece_justificative_0.pdf", content_type: "application/pdf") visit telecharger_pjs_instructeur_dossier_path(procedure, dossier) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 80723180c..869896403 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -47,7 +47,7 @@ Capybara.register_driver :headless_chrome do |app| download_path = Capybara.save_path # Chromedriver 77 requires setting this for headless mode on linux - # Different versions of Chrome/selenium-webdriver require setting differently - jus set them all + # Different versions of Chrome/selenium-webdriver require setting differently - just set them all options.add_preference('download.default_directory', download_path) options.add_preference(:download, default_directory: download_path)