From 90e08d665a542355bb8bda98d4ecc75df6b5962c Mon Sep 17 00:00:00 2001 From: Sina Eftekhar Date: Wed, 3 Jan 2024 10:34:45 +0200 Subject: [PATCH] Add tests for the fix --- lib/decidim/term_customizer/import/importer.rb | 4 +--- .../files/set-translations-with-nils.xlsx | Bin 0 -> 5160 bytes .../term_customizer/import/readers/xlsx_spec.rb | 2 +- spec/shared/translation_importer_examples.rb | 2 +- 4 files changed, 3 insertions(+), 5 deletions(-) create mode 100644 spec/fixtures/files/set-translations-with-nils.xlsx diff --git a/lib/decidim/term_customizer/import/importer.rb b/lib/decidim/term_customizer/import/importer.rb index 93c04cb..e2df4bd 100644 --- a/lib/decidim/term_customizer/import/importer.rb +++ b/lib/decidim/term_customizer/import/importer.rb @@ -52,9 +52,7 @@ def collection_data data_headers = [] reader.new(file).read_rows do |rowdata, index| if index.zero? - data_headers = rowdata.map do |cell| - cell.to_sym if cell.present? - end + data_headers = rowdata.compact_blank.map(&:to_sym) else next if rowdata.blank? diff --git a/spec/fixtures/files/set-translations-with-nils.xlsx b/spec/fixtures/files/set-translations-with-nils.xlsx new file mode 100644 index 0000000000000000000000000000000000000000..b79f969a3fe1e69753b7b80e56ac6ddbacb20051 GIT binary patch literal 5160 zcmaJ_1yodP*B%%eq`OnP8$=|f1f;uXXof~oQjj}HcS@*qgES1?brA$936YQ#q=s+s z-u21v_usqES~KUYnf<=!-SO;aZ%tJo3NZi!0|O8v%VYq!BiM+0b9a!F2QSa=BPi)G^VG*jAuPm@@J3J34MYKQVkW~oXJy|ftkc- ziz4c#NSj3)|8QqhbKs55)@fAn>5|>jWsF|rS$Jwy@s47o&$=11qWI)z{rouYGd4wD z!Bzr|ad~asJWBNzCtja(e{~GD560CiQEu7qb!wq$9bONbBHgp4iN1taz&*s@V<^VL zTN9pq9k!e4oMg3=2573HV}MIS8&?p=mP7_1p8v@(c!+;IL+k-@ceH{)9C@BOJH==Z zx-9VFx1DjKEID(VIZ&kl^&8>)9m%9q|S(Ad=s=U!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ec/lib/decidim/term_customizer/import/readers/xlsx_spec.rb b/spec/lib/decidim/term_customizer/import/readers/xlsx_spec.rb index 0d1780d..270b136 100644 --- a/spec/lib/decidim/term_customizer/import/readers/xlsx_spec.rb +++ b/spec/lib/decidim/term_customizer/import/readers/xlsx_spec.rb @@ -10,6 +10,6 @@ context "with xlsx files containing nils in header" do let(:file) { file_fixture("set-translations-with-nils.xlsx") } - it_behaves_like "translation import reader" + it_behaves_like "translation import reader" end end diff --git a/spec/shared/translation_importer_examples.rb b/spec/shared/translation_importer_examples.rb index 9ad3b38..df37ae0 100644 --- a/spec/shared/translation_importer_examples.rb +++ b/spec/shared/translation_importer_examples.rb @@ -97,7 +97,7 @@ it "yields all the data correctly" do data = [] subject.read_rows do |row, index| - data[index] = row.map(&:to_s) + data[index] = row.compact_blank.map(&:to_s) end expected_array = []