Browse Source

Set support_type to nil if it's not given

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

2
app/services/imports/scheme_location_import_service.rb

@ -208,6 +208,8 @@ module Imports
def support_type(xml_doc)
type = safe_string_as_integer(xml_doc, "support-type")
return unless type
Scheme::SUPPORT_TYPE.value?(type) ? type : 0
end
end

9
spec/services/imports/scheme_location_import_service_spec.rb

@ -217,5 +217,14 @@ RSpec.describe Imports::SchemeLocationImportService do
expect(location.scheme.support_type).to eq("Missing")
end
end
context "and support_type is not answered" do
before { location_xml.at_xpath("//scheme:support-type").content = "" }
it "sets the support type to nil" do
location = location_service.create_scheme_location(location_xml)
expect(location.scheme.support_type).to eq(nil)
end
end
end
end

Loading…
Cancel
Save