Sha256: 2870847972c829ac773689755eccbd4d1f4b83442899e34026fbb280f6bec62e
Contents?: true
Size: 1.05 KB
Versions: 4
Compression:
Stored size: 1.05 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_complete("success", {import_id: import.id}) import end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
importo-3.0.21 | lib/importo/test_helpers.rb |
importo-3.0.20 | lib/importo/test_helpers.rb |
importo-3.0.19 | lib/importo/test_helpers.rb |
importo-3.0.18 | lib/importo/test_helpers.rb |