Browse Source

when the armedforcesspouse is not answered set is as don't know

pull/1331/head
Kat 3 years ago
parent
commit
b66e77350a
  1. 9
      app/services/imports/sales_logs_import_service.rb
  2. 16
      spec/services/imports/sales_logs_import_service_spec.rb

9
app/services/imports/sales_logs_import_service.rb

@ -59,7 +59,7 @@ module Imports
attributes["noint"] = unsafe_string_as_integer(xml_doc, "PartAPurchaser")
attributes["buy2livein"] = unsafe_string_as_integer(xml_doc, "LiveInBuyer2")
attributes["wheel"] = unsafe_string_as_integer(xml_doc, "Q10Wheelchair")
attributes["hholdcount"] = safe_string_as_integer(xml_doc, "LiveInOther") || 0
attributes["hholdcount"] = safe_string_as_integer(xml_doc, "LiveInOther")
attributes["la"] = string_or_nil(xml_doc, "Q14ONSLACode")
attributes["income1"] = safe_string_as_integer(xml_doc, "Q2Person1Income")
attributes["income1nk"] = income_known(unsafe_string_as_integer(xml_doc, "P1IncKnown"))
@ -396,12 +396,9 @@ module Imports
end
end
def default_mscharge_known(attributes)
0 if attributes["ownershipsch"] == 3
end
def set_default_values(attributes)
attributes["mscharge_known"] ||= default_mscharge_known(attributes)
attributes["mscharge_known"] ||= 0 if attributes["ownershipsch"] == 3
attributes["armedforcesspouse"] ||= 7
end
end
end

16
spec/services/imports/sales_logs_import_service_spec.rb

@ -151,6 +151,22 @@ RSpec.describe Imports::SalesLogsImportService do
end
end
context "when the armedforcesspouse is not answered" do
let(:sales_log_id) { "0b4a68df-30cc-474a-93c0-a56ce8fdad3b" }
before do
sales_log_xml.at_xpath("//xmlns:ARMEDFORCESSPOUSE").content = ""
allow(logger).to receive(:warn).and_return(nil)
end
it "sets armedforcesspouse to don't know" do
sales_log_service.send(:create_log, sales_log_xml)
sales_log = SalesLog.find_by(old_id: sales_log_id)
expect(sales_log&.armedforcesspouse).to be(7)
end
end
context "with shared ownership type" do
let(:sales_log_id) { "0ead17cb-1668-442d-898c-0d52879ff592" }

Loading…
Cancel
Save