diff --git a/app/models/validations/local_authority_validations.rb b/app/models/validations/local_authority_validations.rb index 23ac8c590..0409572b9 100644 --- a/app/models/validations/local_authority_validations.rb +++ b/app/models/validations/local_authority_validations.rb @@ -10,13 +10,6 @@ module Validations::LocalAuthorityValidations end def validate_la(record) - if record.la.present? && !LONDON_BOROUGHS.include?(record.la) && record.is_london_rent? - record.errors.add :la, I18n.t("validations.property.la.london_rent") - if record.postcode_known? && record.postcode_full.present? - record.errors.add :postcode_full, I18n.t("validations.property.la.london_rent_postcode") - end - end - if record.la_known? && record.la.blank? record.errors.add :la, I18n.t("validations.property.la.la_known") end @@ -28,38 +21,4 @@ module Validations::LocalAuthorityValidations record.errors.add :la, I18n.t("validations.property.la.la_invalid_for_org", org_name:, la_name:) end end - - LONDON_BOROUGHS = %w[E09000001 - E09000002 - E09000003 - E09000004 - E09000005 - E09000006 - E09000007 - E09000008 - E09000009 - E09000010 - E09000011 - E09000012 - E09000013 - E09000014 - E09000015 - E09000016 - E09000017 - E09000018 - E09000019 - E09000020 - E09000021 - E09000022 - E09000023 - E09000024 - E09000025 - E09000026 - E09000027 - E09000028 - E09000029 - E09000030 - E09000031 - E09000032 - E09000033].freeze end diff --git a/config/locales/en.yml b/config/locales/en.yml index 2d66ac916..5db7495d1 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -67,8 +67,6 @@ en: offered: relet_number: "Number of times the property has been re-let must be between 0 and 20" la: - london_rent: "Local authority must be in London" - london_rent_postcode: "The postcode must be a London postcode because you told us the rent type is London Affordable Rent or London Living Rent" la_known: "Enter name of local authority" la_invalid_for_org: "%{org_name} does not operate in %{la_name}" rsnvac: diff --git a/spec/models/validations/local_authority_validations_spec.rb b/spec/models/validations/local_authority_validations_spec.rb index ddd3afe8f..1ad97a72f 100644 --- a/spec/models/validations/local_authority_validations_spec.rb +++ b/spec/models/validations/local_authority_validations_spec.rb @@ -38,35 +38,12 @@ RSpec.describe Validations::LocalAuthorityValidations do describe "#validate_la" do context "when the rent type is London affordable" do - let(:expected_error) { I18n.t("validations.property.la.london_rent") } - - it "validates that the local authority is in London" do - record.la = "E07000105" - record.rent_type = 2 - local_auth_validator.validate_la(record) - expect(record.errors["la"]).to include(match(expected_error)) - expect(record.errors["postcode_full"]).to be_empty - end - it "expects that the local authority is in London" do record.la = "E09000033" record.rent_type = 2 local_auth_validator.validate_la(record) expect(record.errors["la"]).to be_empty end - - context "when the la has been derived from a known postcode" do - let(:expected_error) { I18n.t("validations.property.la.london_rent_postcode") } - - it "also adds an error to the postcode field" do - record.la = "E07000105" - record.rent_type = 2 - record.postcode_known = 1 - record.postcode_full = "BN18 7TR" - local_auth_validator.validate_la(record) - expect(record.errors["postcode_full"]).to include(match(expected_error)) - end - end end context "when previous la is known" do diff --git a/spec/services/imports/organisation_la_import_service_spec.rb b/spec/services/imports/organisation_la_import_service_spec.rb index c0cf0cc4c..8247c2b36 100644 --- a/spec/services/imports/organisation_la_import_service_spec.rb +++ b/spec/services/imports/organisation_la_import_service_spec.rb @@ -6,9 +6,10 @@ RSpec.describe Imports::OrganisationLaImportService do let(:old_id) { "00013f30e159d7f72a3abe9ea93fb5b685d311e4" } let(:import_file) { File.open("#{fixture_directory}/#{old_id}.xml") } let(:storage_service) { instance_double(StorageService) } + let(:logger) { instance_double(ActiveSupport::Logger) } context "when importing data protection confirmations" do - subject(:import_service) { described_class.new(storage_service) } + subject(:import_service) { described_class.new(storage_service, logger) } before do allow(storage_service) @@ -22,8 +23,8 @@ RSpec.describe Imports::OrganisationLaImportService do context "when the organisation in the import file doesn't exist in the system" do it "does not create an organisation la record" do - expect { import_service.create_organisation_las("organisation_la_directory") } - .to raise_error(ActiveRecord::RecordInvalid, /Organisation must exist/) + expect(logger).to receive(:error).with(/Organisation must exist/) + import_service.create_organisation_las("organisation_la_directory") end end