From dcdf33e4fdf95d5a119dbfb7dcd55d24adaabf55 Mon Sep 17 00:00:00 2001 From: seb-by-ouidou Date: Tue, 27 Jun 2023 15:40:08 +0200 Subject: [PATCH] fix spec (% 10000 and assert_performed_jobs) --- spec/services/procedure_archive_service_spec.rb | 10 +++++----- spec/system/instructeurs/instruction_spec.rb | 10 ++++++---- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/spec/services/procedure_archive_service_spec.rb b/spec/services/procedure_archive_service_spec.rb index c2d314e63..94d2dce81 100644 --- a/spec/services/procedure_archive_service_spec.rb +++ b/spec/services/procedure_archive_service_spec.rb @@ -36,7 +36,7 @@ describe ProcedureArchiveService do "#{service.send(:zip_root_folder, archive)}/dossier-#{dossier.id}/", "#{service.send(:zip_root_folder, archive)}/dossier-#{dossier.id}/pieces_justificatives/", "#{service.send(:zip_root_folder, archive)}/dossier-#{dossier.id}/pieces_justificatives/attestation-dossier--05-03-2021-00-00-#{dossier.attestation.pdf.id % 10000}.pdf", - "#{service.send(:zip_root_folder, archive)}/dossier-#{dossier.id}/export-#{dossier.id}-05-03-2021-00-00-#{dossier.id}.pdf" + "#{service.send(:zip_root_folder, archive)}/dossier-#{dossier.id}/export-#{dossier.id}-05-03-2021-00-00-#{dossier.id % 10000}.pdf" ] expect(files.map(&:filename)).to match_array(structure) end @@ -56,7 +56,7 @@ describe ProcedureArchiveService do "#{service.send(:zip_root_folder, archive)}/-LISTE-DES-FICHIERS-EN-ERREURS.txt", "#{service.send(:zip_root_folder, archive)}/dossier-#{dossier.id}/", "#{service.send(:zip_root_folder, archive)}/dossier-#{dossier.id}/pieces_justificatives/", - "#{service.send(:zip_root_folder, archive)}/dossier-#{dossier.id}/export-#{dossier.id}-05-03-2021-00-00-#{dossier.id}.pdf" + "#{service.send(:zip_root_folder, archive)}/dossier-#{dossier.id}/export-#{dossier.id}-05-03-2021-00-00-#{dossier.id % 10000}.pdf" ] expect(files.map(&:filename)).to match_array(structure) end @@ -104,7 +104,7 @@ describe ProcedureArchiveService do "#{service.send(:zip_root_folder, archive)}/dossier-#{dossier.id}/", "#{service.send(:zip_root_folder, archive)}/dossier-#{dossier.id}/export-dossier-05-03-2020-00-00-1.pdf", "#{service.send(:zip_root_folder, archive)}/dossier-#{dossier.id}/pieces_justificatives/", - "#{service.send(:zip_root_folder, archive)}/dossier-#{dossier.id}/export-#{dossier.id}-05-03-2021-00-00-#{dossier.id}.pdf" + "#{service.send(:zip_root_folder, archive)}/dossier-#{dossier.id}/export-#{dossier.id}-05-03-2021-00-00-#{dossier.id % 10000}.pdf" ] expect(zip_entries.map(&:filename)).to match_array(structure) zip_entries.map do |entry| @@ -137,9 +137,9 @@ describe ProcedureArchiveService do "#{service.send(:zip_root_folder, archive)}/dossier-#{dossier.id}/", "#{service.send(:zip_root_folder, archive)}/dossier-#{dossier.id}/pieces_justificatives/", "#{service.send(:zip_root_folder, archive)}/dossier-#{dossier.id}/pieces_justificatives/attestation-dossier--05-03-2020-00-00-#{dossier.attestation.pdf.id % 10000}.pdf", - "#{service.send(:zip_root_folder, archive)}/dossier-#{dossier.id}/export-#{dossier.id}-05-03-2020-00-00-#{dossier.id}.pdf", + "#{service.send(:zip_root_folder, archive)}/dossier-#{dossier.id}/export-#{dossier.id}-05-03-2020-00-00-#{dossier.id % 10000}.pdf", "#{service.send(:zip_root_folder, archive)}/dossier-#{dossier_2020.id}/", - "#{service.send(:zip_root_folder, archive)}/dossier-#{dossier_2020.id}/export-#{dossier_2020.id}-05-03-2020-00-00-#{dossier_2020.id}.pdf", + "#{service.send(:zip_root_folder, archive)}/dossier-#{dossier_2020.id}/export-#{dossier_2020.id}-05-03-2020-00-00-#{dossier_2020.id % 10000}.pdf", "#{service.send(:zip_root_folder, archive)}/dossier-#{dossier_2020.id}/pieces_justificatives/", "#{service.send(:zip_root_folder, archive)}/dossier-#{dossier_2020.id}/pieces_justificatives/attestation-dossier--05-03-2020-00-00-#{dossier_2020.attestation.pdf.id % 10000}.pdf" ] diff --git a/spec/system/instructeurs/instruction_spec.rb b/spec/system/instructeurs/instruction_spec.rb index a11895bed..1b3d86ff8 100644 --- a/spec/system/instructeurs/instruction_spec.rb +++ b/spec/system/instructeurs/instruction_spec.rb @@ -107,11 +107,12 @@ describe 'Instructing a dossier:', js: true do end scenario 'A instructeur can request an export' do - log_in(instructeur.email, password) + assert_performed_jobs 1 do + log_in(instructeur.email, password) + end click_on procedure.libelle test_statut_bar(a_suivre: 1, tous_les_dossiers: 1) - assert_performed_jobs 1 click_on "Télécharger un dossier" within(:css, '.dossiers-export') do @@ -121,8 +122,9 @@ describe 'Instructing a dossier:', js: true do expect(page).to have_text('Nous générons cet export.') click_on "Télécharger un dossier" expect(page).to have_text('Un export au format .csv est en train d’être généré') - perform_enqueued_jobs(only: ExportJob) - assert_performed_jobs 2 + assert_performed_jobs 2 do + perform_enqueued_jobs(only: ExportJob) + end page.driver.browser.navigate.refresh click_on "Télécharger un dossier"