Browse Source

feat: don't raise "no matching location" error (#1900)

pull/1901/head
natdeanlewissoftwire 1 year ago committed by GitHub
parent
commit
19ad92c21d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      app/services/imports/lettings_logs_import_service.rb
  2. 19
      spec/services/imports/lettings_logs_import_service_spec.rb

3
app/services/imports/lettings_logs_import_service.rb

@ -217,9 +217,6 @@ module Imports
schemes = Scheme.where(old_visible_id: scheme_old_visible_id, owning_organisation_id: attributes["owning_organisation_id"])
location = Location.find_by(old_visible_id: location_old_visible_id, scheme: schemes)
if location.nil? && [location_old_visible_id, scheme_old_visible_id].all?(&:present?) && previous_status != "saved"
raise "No matching location for scheme #{scheme_old_visible_id} and location #{location_old_visible_id} (visible IDs)"
end
if location.present?
# Set the scheme via location, because the scheme old visible ID can be duplicated at import

19
spec/services/imports/lettings_logs_import_service_spec.rb

@ -1248,6 +1248,25 @@ RSpec.describe Imports::LettingsLogsImportService do
end
end
context "and the scheme and location are not valid" do
let(:lettings_log_id) { "0b4a68df-30cc-474a-93c0-a56ce8fdad3b" }
before do
lettings_log_xml.at_xpath("//xmlns:_1cmangroupcode").content = "999"
lettings_log_xml.at_xpath("//xmlns:_1cschemecode").content = "999"
end
it "saves log without location and scheme" do
expect(logger).not_to receive(:warn)
lettings_log_service.send(:create_log, lettings_log_xml)
lettings_log = LettingsLog.find_by(old_id: lettings_log_id)
expect(lettings_log.scheme_id).to be_nil
expect(lettings_log.location_id).to be_nil
expect(lettings_log.status).to eq("in_progress")
end
end
context "and this is a supported housing log with a single location under a scheme" do
let(:lettings_log_id) { "0b4a68df-30cc-474a-93c0-a56ce8fdad3b" }

Loading…
Cancel
Save