|
|
@ -6,7 +6,7 @@ describe "rake core:data_import", type: :task do |
|
|
|
|
|
|
|
|
|
|
|
let(:fixture_path) { "spec/fixtures/softwire_imports/organisations" } |
|
|
|
let(:fixture_path) { "spec/fixtures/softwire_imports/organisations" } |
|
|
|
let(:instance_name) { "paas_import_instance" } |
|
|
|
let(:instance_name) { "paas_import_instance" } |
|
|
|
let(:organisation_type) { "organisation" } |
|
|
|
let(:type) { "organisation" } |
|
|
|
|
|
|
|
|
|
|
|
let(:storage_service) { instance_double(StorageService) } |
|
|
|
let(:storage_service) { instance_double(StorageService) } |
|
|
|
let(:paas_config_service) { instance_double(PaasConfigurationService) } |
|
|
|
let(:paas_config_service) { instance_double(PaasConfigurationService) } |
|
|
@ -19,18 +19,38 @@ describe "rake core:data_import", type: :task do |
|
|
|
|
|
|
|
|
|
|
|
allow(StorageService).to receive(:new).and_return(storage_service) |
|
|
|
allow(StorageService).to receive(:new).and_return(storage_service) |
|
|
|
allow(PaasConfigurationService).to receive(:new).and_return(paas_config_service) |
|
|
|
allow(PaasConfigurationService).to receive(:new).and_return(paas_config_service) |
|
|
|
allow(Imports::OrganisationImportService).to receive(:new).and_return(import_service) |
|
|
|
|
|
|
|
allow(ENV).to receive(:[]) |
|
|
|
allow(ENV).to receive(:[]) |
|
|
|
allow(ENV).to receive(:[]).with("IMPORT_PAAS_INSTANCE").and_return(instance_name) |
|
|
|
allow(ENV).to receive(:[]).with("IMPORT_PAAS_INSTANCE").and_return(instance_name) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
context "when importing organisation data" do |
|
|
|
context "when importing organisation data" do |
|
|
|
|
|
|
|
before do |
|
|
|
|
|
|
|
allow(Imports::OrganisationImportService).to receive(:new).and_return(import_service) |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
it "creates an organisation from the given XML file" do |
|
|
|
it "creates an organisation from the given XML file" do |
|
|
|
expect(StorageService).to receive(:new).with(paas_config_service, instance_name) |
|
|
|
expect(StorageService).to receive(:new).with(paas_config_service, instance_name) |
|
|
|
expect(Imports::OrganisationImportService).to receive(:new).with(storage_service) |
|
|
|
expect(Imports::OrganisationImportService).to receive(:new).with(storage_service) |
|
|
|
expect(import_service).to receive(:create_organisations).with(fixture_path) |
|
|
|
expect(import_service).to receive(:create_organisations).with(fixture_path) |
|
|
|
|
|
|
|
|
|
|
|
task.invoke(organisation_type, fixture_path) |
|
|
|
task.invoke(type, fixture_path) |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
context "when importing user data" do |
|
|
|
|
|
|
|
let(:type) { "user" } |
|
|
|
|
|
|
|
let(:import_service) { instance_double(Imports::UserImportService) } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
before do |
|
|
|
|
|
|
|
allow(Imports::UserImportService).to receive(:new).and_return(import_service) |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it "creates a user from the given XML file" do |
|
|
|
|
|
|
|
expect(StorageService).to receive(:new).with(paas_config_service, instance_name) |
|
|
|
|
|
|
|
expect(Imports::UserImportService).to receive(:new).with(storage_service) |
|
|
|
|
|
|
|
expect(import_service).to receive(:create_users).with(fixture_path) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
task.invoke(type, fixture_path) |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|