diff --git a/spec/models/case_log_spec.rb b/spec/models/case_log_spec.rb index 9051d08bc..3c3fd7b4f 100644 --- a/spec/models/case_log_spec.rb +++ b/spec/models/case_log_spec.rb @@ -227,24 +227,6 @@ RSpec.describe CaseLog do end end - context "when validating local authority" do - it "Has to be london if rent type london affordable rent" do - expect { - described_class.create!(la: "Ashford", - rent_type: "London Affordable rent", - owning_organisation:, - managing_organisation:) - }.to raise_error(ActiveRecord::RecordInvalid) - - expect { - described_class.create!(la: "Westminster", - rent_type: "London Affordable rent", - owning_organisation:, - managing_organisation:) - }.not_to raise_error - end - end - context "with accessibility requirements" do it "validates that only one option can be selected" do expect { @@ -396,6 +378,10 @@ RSpec.describe CaseLog do it "validates property void date" do expect(validator).to receive(:validate_property_void_date) end + + it "validates local authority" do + expect(validator).to receive(:validate_la) + end end describe "status" do diff --git a/spec/models/validations/property_validations_spec.rb b/spec/models/validations/property_validations_spec.rb index da3723e4c..6d1f987a5 100644 --- a/spec/models/validations/property_validations_spec.rb +++ b/spec/models/validations/property_validations_spec.rb @@ -125,4 +125,24 @@ RSpec.describe Validations::PropertyValidations do end end end + + 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 = "Ashford" + record.rent_type = "London Affordable rent" + property_validator.validate_la(record) + expect(record.errors["la"]).to include(match(expected_error)) + end + + it "expects that the local authority is in London" do + record.la = "Westminster" + record.rent_type = "London Affordable rent" + property_validator.validate_la(record) + expect(record.errors["la"]).to be_empty + end + end + end end