Browse Source

Clear incomplete locations on import

pull/1867/head
Kat 3 years ago
parent
commit
8467271b3a
  1. 1
      app/services/imports/lettings_logs_import_service.rb
  2. 26
      spec/services/imports/lettings_logs_import_service_spec.rb

1
app/services/imports/lettings_logs_import_service.rb

@ -323,6 +323,7 @@ module Imports
%i[voiddate after_mrcdate] => %w[voiddate mrcdate majorrepairs], %i[voiddate after_mrcdate] => %w[voiddate mrcdate majorrepairs],
%i[tshortfall more_than_rent] => %w[tshortfall tshortfall_known], %i[tshortfall more_than_rent] => %w[tshortfall tshortfall_known],
%i[scheme_id no_completed_locations] => %w[scheme_id location_id], %i[scheme_id no_completed_locations] => %w[scheme_id location_id],
%i[location_id incomplete] => %w[scheme_id location_id],
%i[beds one_three_bedroom_single_tenant_shared] => %w[beds], %i[beds one_three_bedroom_single_tenant_shared] => %w[beds],
} }

26
spec/services/imports/lettings_logs_import_service_spec.rb

@ -901,6 +901,32 @@ RSpec.describe Imports::LettingsLogsImportService do
end end
end end
context "and unconfirmed/incomplete location is selected" do
let(:lettings_log_id) { "0b4a68df-30cc-474a-93c0-a56ce8fdad3b" }
before do
scheme = Scheme.find_by(old_visible_id: "0123")
scheme.locations.update!(confirmed: false, mobility_type: nil)
scheme.locations << create(:location)
end
it "intercepts the relevant validation error" do
expect { lettings_log_service.send(:create_log, lettings_log_xml) }
.not_to raise_error
end
it "clears out the location answers" do
allow(logger).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).not_to be_nil
expect(lettings_log.location).to be_nil
expect(lettings_log.scheme).to be_nil
end
end
context "and carehome charges are out of range" do context "and carehome charges are out of range" do
let(:lettings_log_id) { "0b4a68df-30cc-474a-93c0-a56ce8fdad3b" } let(:lettings_log_id) { "0b4a68df-30cc-474a-93c0-a56ce8fdad3b" }

Loading…
Cancel
Save