2023-03-22 17:30:37 +01:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-07-27 11:28:54 +02:00
|
|
|
require 'test_helper'
|
|
|
|
|
|
|
|
class ExportTest < ActiveSupport::TestCase
|
|
|
|
test 'export must have a category' do
|
2018-12-12 13:49:14 +01:00
|
|
|
e = Export.new(
|
|
|
|
export_type: 'global',
|
|
|
|
user: User.first,
|
|
|
|
query: '{"query":{"bool":{"must":[{"range":{"date":{"gte":"2016-06-25T02:00:00+02:00","lte":"2016-07-25T23:59:59+02:00"}}}]}}}'
|
|
|
|
)
|
2016-08-03 17:25:00 +02:00
|
|
|
assert e.invalid?
|
2016-07-27 11:28:54 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
test 'export generate an XLSX file' do
|
2018-12-12 13:49:14 +01:00
|
|
|
e = Export.create(
|
|
|
|
category: 'statistics',
|
|
|
|
export_type: 'global',
|
|
|
|
user: User.first,
|
|
|
|
query: '{"query":{"bool":{"must":[{"range":{"date":{"gte":"2016-06-25T02:00:00+02:00","lte":"2016-07-25T23:59:59+02:00"}}}]}}}'
|
|
|
|
)
|
2016-07-27 11:28:54 +02:00
|
|
|
e.save!
|
2022-09-05 11:39:23 +02:00
|
|
|
assert_export_xlsx e
|
2016-07-27 11:28:54 +02:00
|
|
|
end
|
|
|
|
end
|