Browse Source

CLDC-3547: Validate against incomplete schemes being used in logs

pull/2498/head
Rachael Booth 2 years ago
parent
commit
1221069c07
  1. 4
      app/models/validations/setup_validations.rb
  2. 2
      config/locales/en.yml
  3. 10
      spec/models/validations/setup_validations_spec.rb

4
app/models/validations/setup_validations.rb

@ -90,6 +90,10 @@ module Validations::SetupValidations
end end
def validate_scheme(record) def validate_scheme(record)
if record.scheme&.status == :incomplete
record.errors.add :scheme_id, :incomplete, message: I18n.t("validations.setup.scheme.incomplete")
end
scheme_during_startdate_validation(record) scheme_during_startdate_validation(record)
end end

2
config/locales/en.yml

@ -323,6 +323,8 @@ en:
lettype_not_supported_housing: This letting type is general needs, but the needs type is supported housing. Change either the needs type or the letting type. lettype_not_supported_housing: This letting type is general needs, but the needs type is supported housing. Change either the needs type or the letting type.
location: location:
incomplete: "This location is incomplete. Select another location or update this one" incomplete: "This location is incomplete. Select another location or update this one"
scheme:
incomplete: "This scheme is incomplete. Select another scheme or update this one"
property: property:
uprn: uprn:

10
spec/models/validations/setup_validations_spec.rb

@ -511,6 +511,16 @@ RSpec.describe Validations::SetupValidations do
expect(record.errors["scheme_id"]).to be_empty expect(record.errors["scheme_id"]).to be_empty
end end
end end
context "with an incomplete scheme" do
let(:scheme) { create(:scheme, :incomplete) }
it "adds an error to scheme_id" do
record.scheme = scheme
setup_validator.validate_scheme(record)
expect(record.errors["scheme_id"]).to include(I18n.t("validations.setup.scheme.incomplete"))
end
end
end end
describe "#validate_location" do describe "#validate_location" do

Loading…
Cancel
Save