refactor(suffix): be consistent with index suffix

This commit is contained in:
simon lehericey 2024-05-01 21:25:43 +02:00
parent b656867836
commit 585810553f
No known key found for this signature in database
GPG key ID: CDE670D827C7B3C5
2 changed files with 3 additions and 6 deletions

View file

@ -148,11 +148,8 @@ class ExportTemplate < ApplicationRecord
end end
def suffix(attachment, index, row_index) def suffix(attachment, index, row_index)
suffix = "" suffix = "-#{index + 1}"
if index >= 1 && !row_index.nil? suffix += "-#{row_index + 1}" if row_index.present?
suffix += "-#{index + 1}"
suffix += "-#{row_index + 1}" if row_index
end
suffix + attachment.filename.extension_with_delimiter suffix + attachment.filename.extension_with_delimiter
end end

View file

@ -544,7 +544,7 @@ describe ProcedureExportService do
structure = [ structure = [
"#{base_fn}/", "#{base_fn}/",
"#{base_fn}/dossier-#{dossier.id}/", "#{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" "#{base_fn}/dossier-#{dossier.id}/export_#{dossier.id}.pdf"
] ]
expect(files.size).to eq(structure.size) expect(files.size).to eq(structure.size)