2024-04-29 00:17:15 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2023-05-15 11:41:38 +02:00
|
|
|
describe Recovery::Exporter do
|
|
|
|
let(:dossier_ids) { [create(:dossier, :with_individual).id, create(:dossier, :with_individual).id] }
|
2023-05-15 17:41:53 +02:00
|
|
|
let(:fp) { Rails.root.join('spec', 'fixtures', 'export.dump') }
|
2023-05-15 11:41:38 +02:00
|
|
|
subject { Recovery::Exporter.new(dossier_ids:, file_path: fp).dump }
|
|
|
|
|
|
|
|
def cleanup_export_file
|
2023-05-15 17:41:53 +02:00
|
|
|
if File.exist?(fp)
|
|
|
|
FileUtils.rm(fp)
|
|
|
|
end
|
2023-05-15 11:41:38 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
before { cleanup_export_file }
|
|
|
|
after { cleanup_export_file }
|
|
|
|
|
|
|
|
it 'exports dossiers to .dump' do
|
2023-05-15 12:54:20 +02:00
|
|
|
expect { subject }.not_to raise_error
|
2023-05-15 11:41:38 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'exports dossiers local file .dump' do
|
2023-05-15 12:54:20 +02:00
|
|
|
expect { subject }.to change { File.exist?(fp) }
|
2023-05-15 11:41:38 +02:00
|
|
|
.from(false).to(true)
|
|
|
|
end
|
|
|
|
end
|