convert sheet_name to ascii before tuncate to 30 to ensure length < 31 bytes

This commit is contained in:
simon lehericey 2020-09-29 14:01:27 +02:00
parent 29ef5e6785
commit 1eb780b0c9
2 changed files with 7 additions and 3 deletions

View file

@ -73,7 +73,11 @@ class ProcedureExportService
{ instances: table.last, sheet_name: table.first } { instances: table.last, sheet_name: table.first }
end.merge(DEFAULT_STYLES) end.merge(DEFAULT_STYLES)
options[:sheet_name] = options[:sheet_name].truncate(30) # transliterate: convert to ASCII characteres
# to ensure truncate respects 30 bytes
options[:sheet_name] = I18n.transliterate(options[:sheet_name], '')
.truncate(30, omission: '')
options options
end end
end end

View file

@ -356,10 +356,10 @@ describe ProcedureExportService do
end end
end end
context 'with long libelle' do context 'with long libelle composed of utf8 characteres' do
before do before do
procedure.types_de_champ.each do |c| procedure.types_de_champ.each do |c|
c.update!(libelle: "#{c.id} - Quam rem nam maiores numquam dolorem nesciunt. Cum et possimus et aut. Fugit voluptas qui qui.") c.update!(libelle: "#{c.id} - éééé ééé ééé ééééééé ééééééé ééééééé éééééééé. ééé éé éééééééé éé ééé. ééééé éééééééé ééé ééé.")
end end
champ_repetition.champs.each do |c| champ_repetition.champs.each do |c|
c.type_de_champ.update!(libelle: "#{c.id} - Quam rem nam maiores numquam dolorem nesciunt. Cum et possimus et aut. Fugit voluptas qui qui.") c.type_de_champ.update!(libelle: "#{c.id} - Quam rem nam maiores numquam dolorem nesciunt. Cum et possimus et aut. Fugit voluptas qui qui.")