Merge pull request #5646 from betagouv/fix_export_bugs

Fix export bugs
This commit is contained in:
Keirua 2020-09-29 14:16:50 +02:00 committed by GitHub
commit 61ff2f4c36
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 5 deletions

View file

@ -8,7 +8,7 @@
# updated_at :datetime not null
#
class Export < ApplicationRecord
MAX_DUREE_CONSERVATION_EXPORT = 15.minutes
MAX_DUREE_CONSERVATION_EXPORT = 1.hour
enum format: {
csv: 'csv',
@ -24,7 +24,7 @@ class Export < ApplicationRecord
scope :stale, -> { where('updated_at < ?', (Time.zone.now - MAX_DUREE_CONSERVATION_EXPORT)) }
after_save_commit :compute_async
after_create_commit :compute_async
def compute_async
ExportJob.perform_later(self)

View file

@ -73,7 +73,11 @@ class ProcedureExportService
{ instances: table.last, sheet_name: table.first }
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
end
end

View file

@ -356,10 +356,10 @@ describe ProcedureExportService do
end
end
context 'with long libelle' do
context 'with long libelle composed of utf8 characteres' do
before do
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
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.")