Browse Source

Add missing location name

Add more tests for expected values
pull/727/head
Stéphane Meny 3 years ago
parent
commit
c324d03288
No known key found for this signature in database
GPG Key ID: 9D0AFEA988527923
  1. 1
      app/services/imports/scheme_location_import_service.rb
  2. 23
      spec/services/imports/scheme_location_import_service_spec.rb

1
app/services/imports/scheme_location_import_service.rb

@ -55,6 +55,7 @@ module Imports
# wheelchair_adaptation: string_or_nil(xml_doc, "mobility-type"), # wheelchair_adaptation: string_or_nil(xml_doc, "mobility-type"),
begin begin
Location.create!( Location.create!(
name: string_or_nil(xml_doc, "name"),
postcode: string_or_nil(xml_doc, "postcode"), postcode: string_or_nil(xml_doc, "postcode"),
units: safe_string_as_integer(xml_doc, "total-units"), units: safe_string_as_integer(xml_doc, "total-units"),
type_of_unit: safe_string_as_integer(xml_doc, "unit-type"), type_of_unit: safe_string_as_integer(xml_doc, "unit-type"),

23
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 context "when importing a specific scheme location" do
let(:location_xml) { Nokogiri::XML(open_file(fixture_directory, first_location_id)) } 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 context "and the end date is before the current date" do
before do before do
Timecop.freeze(2022, 6, 1) Timecop.freeze(2022, 6, 1)

Loading…
Cancel
Save