Browse Source

Infer mortgagelender as don't know by default

pull/1450/head
Kat 3 years ago
parent
commit
21b90979c3
  1. 1
      app/services/imports/sales_logs_import_service.rb
  2. 17
      spec/services/imports/sales_logs_import_service_spec.rb

1
app/services/imports/sales_logs_import_service.rb

@ -521,6 +521,7 @@ module Imports
attributes["extrabor"] ||= 3 if attributes["mortgageused"] == 1
attributes["socprevten"] ||= 10 if attributes["ownershipsch"] == 1
attributes["fromprop"] ||= 0 if attributes["ownershipsch"] == 1
attributes["mortgagelender"] ||= 0 if attributes["mortgageused"] == 1
# buyer 1 characteristics
attributes["age1_known"] ||= 1

17
spec/services/imports/sales_logs_import_service_spec.rb

@ -167,6 +167,23 @@ RSpec.describe Imports::SalesLogsImportService do
end
end
context "when the mortgage lender is not set" do
let(:sales_log_id) { "discounted_ownership_sales_log" }
before do
sales_log_xml.at_xpath("//xmlns:Q34a").content = ""
allow(logger).to receive(:warn).and_return(nil)
end
it "correctly sets mortgage lender and mortgage lender other" do
sales_log_service.send(:create_log, sales_log_xml)
sales_log = SalesLog.find_by(old_id: sales_log_id)
expect(sales_log&.mortgagelender).to be(0)
expect(sales_log&.mortgagelenderother).to be_nil
end
end
context "with shared ownership type" do
let(:sales_log_id) { "shared_ownership_sales_log" }

Loading…
Cancel
Save