From 4ce4b90e3c3861a423e1e92108b96c2212fd45de Mon Sep 17 00:00:00 2001 From: Giga Chubinidze Date: Mon, 11 Mar 2024 17:27:13 +0400 Subject: [PATCH 1/2] Inventory export for checklists with return delimiter should escape the return sign [SCI-10200] --- app/models/repository_checklist_value.rb | 2 +- app/services/spreadsheet_parser.rb | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/models/repository_checklist_value.rb b/app/models/repository_checklist_value.rb index 302b03943..1f5f1b367 100644 --- a/app/models/repository_checklist_value.rb +++ b/app/models/repository_checklist_value.rb @@ -20,7 +20,7 @@ class RepositoryChecklistValue < ApplicationRecord EXTRA_PRELOAD_INCLUDE = :repository_checklist_items def formatted(separator: ' | ') - repository_checklist_items.pluck(:data).join(separator) + repository_checklist_items.pluck(:data).join(separator).gsub("\n", "\\n") end def export_formatted diff --git a/app/services/spreadsheet_parser.rb b/app/services/spreadsheet_parser.rb index fbdbe6ebd..9f2a71c4c 100644 --- a/app/services/spreadsheet_parser.rb +++ b/app/services/spreadsheet_parser.rb @@ -44,7 +44,10 @@ class SpreadsheetParser if row && i.zero? header = row else - columns = row + escaped_row = row.map do |row| + row.gsub("\\n", "\n") + end + columns = escaped_row end end From 134a3393d4e6df5c10260ba8d20b35edbc0b2c5a Mon Sep 17 00:00:00 2001 From: Giga Chubinidze Date: Mon, 11 Mar 2024 17:39:20 +0400 Subject: [PATCH 2/2] rename loop variable [SCI-10200] --- app/services/spreadsheet_parser.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/services/spreadsheet_parser.rb b/app/services/spreadsheet_parser.rb index 9f2a71c4c..a89f1f1d0 100644 --- a/app/services/spreadsheet_parser.rb +++ b/app/services/spreadsheet_parser.rb @@ -44,8 +44,8 @@ class SpreadsheetParser if row && i.zero? header = row else - escaped_row = row.map do |row| - row.gsub("\\n", "\n") + escaped_row = row.map do |cell| + cell.gsub("\\n", "\n") end columns = escaped_row end