From ff0bf5319f1660226426e543a7208183fb513a05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Meny?= Date: Mon, 25 Apr 2022 11:53:16 +0100 Subject: [PATCH] Add case logs import rake type (#495) --- lib/tasks/data_import.rake | 2 ++ spec/lib/tasks/data_import_spec.rb | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/lib/tasks/data_import.rake b/lib/tasks/data_import.rake index ad15b766e..6a64c1fd0 100644 --- a/lib/tasks/data_import.rake +++ b/lib/tasks/data_import.rake @@ -18,6 +18,8 @@ namespace :core do Imports::OrganisationLaImportService.new(storage_service).create_organisation_las(path) when "organisation-rent-periods" Imports::OrganisationRentPeriodImportService.new(storage_service).create_organisation_rent_periods(path) + when "case-logs" + Imports::CaseLogsImportService.new(storage_service).create_logs(path) else raise "Type #{type} is not supported by data_import" end diff --git a/spec/lib/tasks/data_import_spec.rb b/spec/lib/tasks/data_import_spec.rb index 4e225bfe3..3d69913a9 100644 --- a/spec/lib/tasks/data_import_spec.rb +++ b/spec/lib/tasks/data_import_spec.rb @@ -108,6 +108,24 @@ describe "rake core:data_import", type: :task do end end + context "when importing case logs" do + let(:type) { "case-logs" } + let(:import_service) { instance_double(Imports::CaseLogsImportService) } + let(:fixture_path) { "spec/fixtures/softwire_imports/case_logs" } + + before do + allow(Imports::CaseLogsImportService).to receive(:new).and_return(import_service) + end + + it "creates case logs from the given XML file" do + expect(StorageService).to receive(:new).with(paas_config_service, instance_name) + expect(Imports::CaseLogsImportService).to receive(:new).with(storage_service) + expect(import_service).to receive(:create_logs).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