2023-03-22 17:30:37 +01:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2022-09-05 11:39:23 +02:00
|
|
|
require 'test_helper'
|
|
|
|
|
|
|
|
class UsersExportServiceTest < ActiveSupport::TestCase
|
|
|
|
setup do
|
|
|
|
@user = User.admins.first
|
|
|
|
end
|
|
|
|
|
|
|
|
test 'export reservations' do
|
|
|
|
export = Export.new(category: 'users', export_type: 'reservations', user: @user)
|
|
|
|
assert export.save, 'unable to save reservations export'
|
|
|
|
UsersExportWorker.new.perform(export.id)
|
|
|
|
|
|
|
|
assert File.exist?(export.file), 'Export XLSX was not generated'
|
|
|
|
|
|
|
|
File.delete(export.file)
|
|
|
|
end
|
|
|
|
|
|
|
|
test 'export subscriptions' do
|
|
|
|
export = Export.new(category: 'users', export_type: 'subscriptions', user: @user)
|
|
|
|
assert export.save, 'unable to save subscriptions export'
|
|
|
|
UsersExportWorker.new.perform(export.id)
|
|
|
|
|
|
|
|
assert File.exist?(export.file), 'Export XLSX was not generated'
|
|
|
|
|
|
|
|
File.delete(export.file)
|
|
|
|
end
|
|
|
|
|
|
|
|
test 'export members' do
|
|
|
|
export = Export.new(category: 'users', export_type: 'members', user: @user)
|
|
|
|
assert export.save, 'unable to save members export'
|
|
|
|
UsersExportWorker.new.perform(export.id)
|
|
|
|
|
|
|
|
assert File.exist?(export.file), 'Export XLSX was not generated'
|
|
|
|
|
|
|
|
File.delete(export.file)
|
|
|
|
end
|
|
|
|
end
|