Browse Source

Run export service directly (#1868)

pull/1869/head
kosiakkatrina 1 year ago committed by GitHub
parent
commit
63f4599183
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      lib/tasks/data_export.rake
  2. 19
      spec/lib/tasks/data_export_spec.rb

8
lib/tasks/data_export.rake

@ -10,4 +10,12 @@ namespace :core do
DataExportXmlJob.perform_later(full_update:) DataExportXmlJob.perform_later(full_update:)
end end
desc "Export all data XMLs for import into Central Data System (CDS)"
task full_data_export_xml: :environment do |_task, _args|
storage_service = Storage::S3Service.new(PlatformHelper.is_paas? ? Configuration::PaasConfigurationService.new : Configuration::EnvConfigurationService.new, ENV["EXPORT_PAAS_INSTANCE"])
export_service = Exports::LettingsLogExportService.new(storage_service)
export_service.export_xml_lettings_logs(full_update: true)
end
end end

19
spec/lib/tasks/data_export_spec.rb

@ -26,4 +26,23 @@ describe "rake core:data_export", type: task do
expect { task.invoke }.to enqueue_job(DataExportXmlJob) expect { task.invoke }.to enqueue_job(DataExportXmlJob)
end end
end end
context "when running full export" do
let(:storage_service) { instance_double(Storage::S3Service) }
let(:paas_config_service) { instance_double(Configuration::PaasConfigurationService) }
let(:export_service) { instance_double(Exports::LettingsLogExportService) }
let(:task) { Rake::Task["core:full_data_export_xml"] }
before do
allow(Storage::S3Service).to receive(:new).and_return(storage_service)
allow(Configuration::PaasConfigurationService).to receive(:new).and_return(paas_config_service)
allow(Exports::LettingsLogExportService).to receive(:new).and_return(export_service)
end
it "calls the export service" do
expect(export_service).to receive(:export_xml_lettings_logs).with(full_update: true)
task.invoke
end
end
end end

Loading…
Cancel
Save