Browse Source

LA validations

pull/304/head
baarkerlounger 3 years ago
parent
commit
720765c9fe
  1. 22
      spec/models/case_log_spec.rb
  2. 20
      spec/models/validations/property_validations_spec.rb

22
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

20
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

Loading…
Cancel
Save