diff --git a/app/services/imports/scheme_location_import_service.rb b/app/services/imports/scheme_location_import_service.rb index 8a30f7d0b..bd7906c54 100644 --- a/app/services/imports/scheme_location_import_service.rb +++ b/app/services/imports/scheme_location_import_service.rb @@ -55,6 +55,7 @@ module Imports # wheelchair_adaptation: string_or_nil(xml_doc, "mobility-type"), begin Location.create!( + name: string_or_nil(xml_doc, "name"), postcode: string_or_nil(xml_doc, "postcode"), units: safe_string_as_integer(xml_doc, "total-units"), type_of_unit: safe_string_as_integer(xml_doc, "unit-type"), diff --git a/spec/services/imports/scheme_location_import_service_spec.rb b/spec/services/imports/scheme_location_import_service_spec.rb index 16f6a8d7d..f87fc3724 100644 --- a/spec/services/imports/scheme_location_import_service_spec.rb +++ b/spec/services/imports/scheme_location_import_service_spec.rb @@ -129,6 +129,29 @@ RSpec.describe Imports::SchemeLocationImportService do context "when importing a specific scheme location" do let(:location_xml) { Nokogiri::XML(open_file(fixture_directory, first_location_id)) } + it "matches expected location values" do + location = location_service.create_scheme_location(location_xml) + expect(location.name).to eq("Location 1") + expect(location.postcode).to eq("S44 6EJ") + expect(location.units).to eq(5) + expect(location.type_of_unit).to eq("Bungalow") + expect(location.old_id).to eq(first_location_id) + expect(location.old_visible_id).to eq(10) + expect(location.scheme).to eq(scheme) + end + + it "matches expected schemes values" do + location = location_service.create_scheme_location(location_xml) + expect(location.scheme.scheme_type).to eq("Housing for older people") + expect(location.scheme.registered_under_care_act).to eq("No") + expect(location.scheme.support_type).to eq("Low levels of support") + expect(location.scheme.intended_stay).to eq("Permanent") + expect(location.scheme.primary_client_group).to eq("Older people with support needs") + expect(location.scheme.secondary_client_group).to be_nil + expect(location.scheme.sensitive).to eq("No") + expect(location.scheme.end_date).to eq("2050-12-31") + end + context "and the end date is before the current date" do before do Timecop.freeze(2022, 6, 1)