Sha256: a78ef6e913661748cfefdfaa9e06b2b2ca17118fcab7fb61f70a893d80c756f9
Contents?: true
Size: 1.04 KB
Versions: 2
Compression:
Stored size: 1.04 KB
Contents
# frozen_string_literal: true require "axlsx" require "roo/excelx" module Importo module TestHelpers def simple_sheet(an_array, sheet_name: "Import") xls = Axlsx::Package.new workbook = xls.workbook sheet = workbook.add_worksheet(name: sheet_name) an_array.each do |a| sheet.add_row a end xls.to_stream end def sample_sheet(kind, locale: I18n.locale) excel = Importo::Import.new(kind: kind, locale: locale).importer.sample_file Roo::Excelx.new(excel.set_encoding("BINARY")) end def import_sheet(kind, sheet, filename: "import.xlsx", locale: I18n.locale, owner: @owner) import = Importo::Import.new(kind: kind, locale: locale, importo_ownable: owner) import.original.attach(io: sheet, filename: filename, content_type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", identify: false) import.save! ImportService.perform(import: import) ImportJobCallback.new.on_success({import_id: import.id}) import end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
importo-3.0.17 | lib/importo/test_helpers.rb |
importo-3.0.16 | lib/importo/test_helpers.rb |