diff --git a/app/models/export_template.rb b/app/models/export_template.rb index 136a75999..4d9bc5f39 100644 --- a/app/models/export_template.rb +++ b/app/models/export_template.rb @@ -148,11 +148,8 @@ class ExportTemplate < ApplicationRecord end def suffix(attachment, index, row_index) - suffix = "" - if index >= 1 && !row_index.nil? - suffix += "-#{index + 1}" - suffix += "-#{row_index + 1}" if row_index - end + suffix = "-#{index + 1}" + suffix += "-#{row_index + 1}" if row_index.present? suffix + attachment.filename.extension_with_delimiter end diff --git a/spec/services/procedure_export_service_spec.rb b/spec/services/procedure_export_service_spec.rb index 9109124f4..b463675be 100644 --- a/spec/services/procedure_export_service_spec.rb +++ b/spec/services/procedure_export_service_spec.rb @@ -544,7 +544,7 @@ describe ProcedureExportService do structure = [ "#{base_fn}/", "#{base_fn}/dossier-#{dossier.id}/", - "#{base_fn}/dossier-#{dossier.id}/piece_justificative-#{dossier.id}.txt", + "#{base_fn}/dossier-#{dossier.id}/piece_justificative-#{dossier.id}-1.txt", "#{base_fn}/dossier-#{dossier.id}/export_#{dossier.id}.pdf" ] expect(files.size).to eq(structure.size)