Sha256: 2e47597284d237fae7cb7055474f96907e082369ecb8d83bcd13677bf76cfcb9

Contents?: true

Size: 1.63 KB

Versions: 3

Compression:

Stored size: 1.63 KB

Contents

require 'test_helper'

class OdsTest < ActiveSupport::TestCase

  def setup
    DatabaseCleaner.start

    FileUtils.mkdir_p('tmp/ods')

    10.times.each do
      CustomPost.create(name: SecureRandom.hex, content: SecureRandom.hex, age: 2)
    end

    @headers = ['test1', 'test2','test3']
    @data = [
      ['row1','test1'],
      ['row2 c1', nil, '123'],
      ['the',Date.today,Time.now]
    ]
    @options = {
      headers: true,
      header_style: {background_color: 'AAAAAA', color: 'FFFFFF', align: :center, font_name: 'Arial', font_size: 10, bold: false, italic: false, underline: false},
      row_style: {background_color: nil, color: '000000', align: :left, font_name: 'Arial', font_size: 10, bold: false, italic: false, underline: false},
      sheet_name: 'My Project Export',
      column_styles: [],
      range_styles: [],
      merges: [],
      borders: [],
      column_types: [:string, :date, :date]
    }
  end

  def test_empty_model
    CustomPost.delete_all
    File.open('tmp/ods/empty_model.ods','w+b') do |f|
      f.write CustomPost.to_ods
    end
  end

  def test_empty_sa
    File.open('tmp/ods/empty_sa.ods','w+b') do |f|
      f.write SpreadsheetArchitect.to_ods(data: [])
    end
  end

  def test_sa
    File.open('tmp/ods/sa.ods','w+b') do |f|
      f.write SpreadsheetArchitect.to_ods(headers: @headers, data: @data)
    end
  end

  def test_model
    File.open('tmp/ods/model.ods','w+b') do |f|
      f.write CustomPost.to_ods
    end
  end

  def test_options
    File.open('tmp/ods/model_options.ods','w+b') do |f|
      f.write CustomPost.to_ods(@options)
    end
  end

  def teardown
    DatabaseCleaner.clean
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
spreadsheet_architect-2.0.2 test/rails_app/test/models/ods_test.rb
spreadsheet_architect-2.0.1 test/rails_app/test/models/ods_test.rb
spreadsheet_architect-2.0.0 test/rails_app/test/models/ods_test.rb