Commit e977cb42 by Ivan Lan

feat: 空保护 & update export spec

parent 1cfae215
......@@ -42,7 +42,7 @@ class TalltyImportExport::ExportPayload::Cell
end
def divise
if @header.children.present?
if @header.children.present? && @value.value
new_cells = @header.children.map do |child_header|
if (child_header.children.present?)
val = @value.value[child_header.key.to_sym]
......
......@@ -9,7 +9,7 @@ class TalltyImportExport::ExportPayload::CellColumn
@cell_clusters = []
@value_handler = value_handler
if header.children
if header.children && @value.value
@cell_clusters = (@value.value[header.key.to_sym] || []).map do |val|
TalltyImportExport::ExportPayload::Cell.new(
@header,
......@@ -46,7 +46,7 @@ class TalltyImportExport::ExportPayload::CellColumn
depth_to_cells_mapping = @flatten_cells.group_by { |cell| [cell.header.seq] }
@tallest_cell_cluster = depth_to_cells_mapping.values.max { |a, b| a.count <=> b.count }
@tallest_cell_cluster = depth_to_cells_mapping.values.max { |a, b| a.count <=> b.count } || []
self
end
......
......@@ -82,7 +82,7 @@ RSpec.describe TalltyImportExport::Importable do
it 'export' do
# TalltyImportExport::ExportForm.new.export_workbook nil, [@payload], { headers: @header_h[:items] }
TalltyImportExport::ExportForm.new(nil).export_xlsx [@payload, @payload], { headers: @header_h[:items] }
TalltyImportExport::ExportForm.new(nil).export_xlsx [@payload, nil, @payload], { headers: @header_h[:items] }
end
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment