Browse Source

Add test for deactivation period

pull/1428/head
Kat 3 years ago
parent
commit
977573d3b4
  1. 1
      app/services/imports/scheme_location_import_service.rb
  2. 7
      spec/services/imports/scheme_location_import_service_spec.rb

1
app/services/imports/scheme_location_import_service.rb

@ -113,6 +113,7 @@ module Imports
if attributes["end_date"] if attributes["end_date"]
location.location_deactivation_periods.create!(deactivation_date: attributes["end_date"]) location.location_deactivation_periods.create!(deactivation_date: attributes["end_date"])
end end
location
rescue ActiveRecord::RecordNotUnique rescue ActiveRecord::RecordNotUnique
@logger.warn("Location is already present with legacy ID #{attributes['location_old_id']}, skipping") @logger.warn("Location is already present with legacy ID #{attributes['location_old_id']}, skipping")
rescue ActiveRecord::RecordInvalid rescue ActiveRecord::RecordInvalid

7
spec/services/imports/scheme_location_import_service_spec.rb

@ -156,10 +156,15 @@ RSpec.describe Imports::SchemeLocationImportService do
expect(location.scheme.primary_client_group).to eq("Older people with support needs") 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.secondary_client_group).to be_nil
expect(location.scheme.sensitive).to eq("No") expect(location.scheme.sensitive).to eq("No")
expect(location.scheme.end_date).to eq("2050-12-31")
expect(location.scheme.confirmed).to be_truthy expect(location.scheme.confirmed).to be_truthy
end end
it "creates a deactivation period" do
location = location_service.create_scheme_location(location_xml)
expect(location.location_deactivation_periods.count).to eq(1)
expect(location.location_deactivation_periods.first.deactivation_date).to eq(Time.zone.local(2050, 12, 31))
end
context "and we import the same location twice" do context "and we import the same location twice" do
before { location_service.create_scheme_location(location_xml) } before { location_service.create_scheme_location(location_xml) }

Loading…
Cancel
Save