Browse Source

Import task

pull/484/head
baarkerlounger 3 years ago
parent
commit
feefa4f358
  1. 4
      lib/tasks/data_import.rake
  2. 18
      spec/lib/tasks/data_import_spec.rb

4
lib/tasks/data_import.rake

@ -14,8 +14,8 @@ namespace :core do
Imports::UserImportService.new(storage_service).create_users(path)
when "data-protection-confirmation"
Imports::DataProtectionConfirmationImportService.new(storage_service).create_data_protection_confirmations(path)
when "organisation_las"
Imports::OrganisationLaImportService.new(storage_service).create_organisation_la(path)
when "organisation-las"
Imports::OrganisationLaImportService.new(storage_service).create_organisation_las(path)
else
raise "Type #{type} is not supported by data_import"
end

18
spec/lib/tasks/data_import_spec.rb

@ -72,6 +72,24 @@ describe "rake core:data_import", type: :task do
end
end
context "when importing organisation local authority data" do
let(:type) { "organisation-las" }
let(:import_service) { instance_double(Imports::OrganisationLaImportService) }
let(:fixture_path) { "spec/fixtures/softwire_imports/organisation_las" }
before do
allow(Imports::OrganisationLaImportService).to receive(:new).and_return(import_service)
end
it "creates an organisation la from the given XML file" do
expect(StorageService).to receive(:new).with(paas_config_service, instance_name)
expect(Imports::OrganisationLaImportService).to receive(:new).with(storage_service)
expect(import_service).to receive(:create_organisation_las).with(fixture_path)
task.invoke(type, fixture_path)
end
end
it "raises an exception if no parameters are provided" do
expect { task.invoke }.to raise_error(/Usage/)
end

Loading…
Cancel
Save