Browse Source

Import support type as missing

pull/1561/head
Kat 3 years ago
parent
commit
3a66137f5f
  1. 7
      app/services/imports/scheme_location_import_service.rb
  2. 9
      spec/services/imports/scheme_location_import_service_spec.rb

7
app/services/imports/scheme_location_import_service.rb

@ -77,7 +77,7 @@ module Imports
attributes["scheme_type"] = safe_string_as_integer(xml_doc, "scheme-type")
registered_under_care_act = safe_string_as_integer(xml_doc, "reg-home-type")
attributes["registered_under_care_act"] = registered_under_care_act&.zero? ? nil : registered_under_care_act
attributes["support_type"] = safe_string_as_integer(xml_doc, "support-type")
attributes["support_type"] = support_type(xml_doc)
attributes["intended_stay"] = string_or_nil(xml_doc, "intended-stay")
attributes["mobility_type"] = string_or_nil(xml_doc, "mobility-type")
attributes["primary_client_group"] = string_or_nil(xml_doc, "client-group-1")
@ -205,5 +205,10 @@ module Imports
date = string_or_nil(xml_doc, attribute)
Time.zone.parse(date) if date
end
def support_type(xml_doc)
type = safe_string_as_integer(xml_doc, "support-type")
Scheme::SUPPORT_TYPE.value?(type) ? type : 0
end
end
end

9
spec/services/imports/scheme_location_import_service_spec.rb

@ -208,5 +208,14 @@ RSpec.describe Imports::SchemeLocationImportService do
expect(location.scheme.confirmed).to be_falsey
end
end
context "and support_type is not a valid one" do
before { location_xml.at_xpath("//scheme:support-type").content = "1" }
it "sets the support type to missing" do
location = location_service.create_scheme_location(location_xml)
expect(location.scheme.support_type).to eq("Missing")
end
end
end
end

Loading…
Cancel
Save