diff --git a/app/services/imports/scheme_location_import_service.rb b/app/services/imports/scheme_location_import_service.rb index 49c1e91c5..a26139aec 100644 --- a/app/services/imports/scheme_location_import_service.rb +++ b/app/services/imports/scheme_location_import_service.rb @@ -97,7 +97,7 @@ module Imports end def add_location(scheme, attributes) - location = Location.new( + location = Location.create!( name: attributes["location_name"], postcode: attributes["postcode"], mobility_type: attributes["mobility_type"], @@ -108,8 +108,6 @@ module Imports startdate: attributes["start_date"], scheme:, ) - confirm_scheme_or_location(location) - location.save! if attributes["end_date"] location.location_deactivation_periods.create!(deactivation_date: attributes["end_date"]) end diff --git a/spec/services/imports/scheme_location_import_service_spec.rb b/spec/services/imports/scheme_location_import_service_spec.rb index 0d7b4cbd4..186fba818 100644 --- a/spec/services/imports/scheme_location_import_service_spec.rb +++ b/spec/services/imports/scheme_location_import_service_spec.rb @@ -16,6 +16,11 @@ RSpec.describe Imports::SchemeLocationImportService do File.open("#{directory}/#{filename}.xml") end + before do + WebMock.stub_request(:get, /api.postcodes.io\/postcodes/) + .to_return(status: 200, body: '{"status":200,"result":{"admin_district":"Westminster","codes":{"admin_district":"E08000035"}}}', headers: {}) + end + context "when importing scheme locations" do let(:remote_folder) { "schemes" } @@ -145,6 +150,7 @@ RSpec.describe Imports::SchemeLocationImportService do expect(location.old_visible_id).to eq("10") expect(location.startdate).to eq("1900-01-01") expect(location.scheme).to eq(scheme) + expect(location.confirmed).to eq(true) end it "matches expected schemes values" do