Browse Source

Ensure imported schemes are confirmed (#802)

pull/803/head v0.2.2
baarkerlounger 2 years ago committed by GitHub
parent
commit
842beac14b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      app/services/imports/scheme_location_import_service.rb
  2. 7
      spec/services/imports/scheme_location_import_service_spec.rb

2
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

7
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

Loading…
Cancel
Save