From 842beac14ba0787efdd6170e14bc4f0aa9982846 Mon Sep 17 00:00:00 2001 From: baarkerlounger <5101747+baarkerlounger@users.noreply.github.com> Date: Tue, 2 Aug 2022 13:50:02 +0100 Subject: [PATCH] Ensure imported schemes are confirmed (#802) --- app/services/imports/scheme_location_import_service.rb | 2 ++ .../imports/scheme_location_import_service_spec.rb | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/app/services/imports/scheme_location_import_service.rb b/app/services/imports/scheme_location_import_service.rb index 9c29f67e2..17f96d33d 100644 --- a/app/services/imports/scheme_location_import_service.rb +++ b/app/services/imports/scheme_location_import_service.rb @@ -36,6 +36,7 @@ module Imports secondary_client_group: attributes["secondary_client_group"], sensitive: attributes["sensitive"], end_date: attributes["end_date"], + confirmed: true, # These values were set by the scheme import (management groups) owning_organisation_id: source_scheme.owning_organisation_id, managing_organisation_id: source_scheme.managing_organisation_id, @@ -56,6 +57,7 @@ module Imports secondary_client_group: attributes["secondary_client_group"], sensitive: attributes["sensitive"], end_date: attributes["end_date"], + confirmed: true, ) scheme end diff --git a/spec/services/imports/scheme_location_import_service_spec.rb b/spec/services/imports/scheme_location_import_service_spec.rb index 8683087cb..7f9e33374 100644 --- a/spec/services/imports/scheme_location_import_service_spec.rb +++ b/spec/services/imports/scheme_location_import_service_spec.rb @@ -10,7 +10,7 @@ RSpec.describe Imports::SchemeLocationImportService do let(:first_location_id) { "0ae7ad6dc0f1cf7ef33c18cc8c108bebc1b4923e" } let(:second_location_id) { "0bb3836b70b4dd9903263d5a764a5c45b964a89d" } - let!(:scheme) { FactoryBot.create(:scheme, service_name: "Management Group", old_id: "6d6d7618b58affe2a150a5ef2e9f4765fa6cd05d") } + let!(:scheme) { FactoryBot.create(:scheme, service_name: "Management Group", old_id: "6d6d7618b58affe2a150a5ef2e9f4765fa6cd05d", confirmed: nil) } def open_file(directory, filename) File.open("#{directory}/#{filename}.xml") @@ -39,6 +39,11 @@ RSpec.describe Imports::SchemeLocationImportService do .to change(Location, :count).by(2) .and(change(Scheme, :count).by(0)) end + + it "successfully sets the scheme to confirmed" do + expect { location_service.create_scheme_locations(remote_folder) } + .to change { scheme.reload.confirmed }.from(nil).to(true) + end end context "when importing different scheme locations" do