Browse Source

CLDC-4269: update depends_on for person_known and update tests

pull/3332/head
Nat Dean-Lewis 2 weeks ago
parent
commit
be85adde90
  1. 5
      app/models/form/lettings/pages/person_known.rb
  2. 12
      spec/models/validations/household_validations_spec.rb

5
app/models/form/lettings/pages/person_known.rb

@ -2,7 +2,10 @@ class Form::Lettings::Pages::PersonKnown < ::Form::Page
def initialize(id, hsh, subsection, person_index:)
super(id, hsh, subsection)
@id = "person_#{person_index}_known"
@depends_on = (person_index..8).map { |index| { "hhmemb" => index } }
@depends_on = [{ "hhmemb" => {
"operator" => ">=",
"operand" => @person_index,
} }]
@person_index = person_index
end

12
spec/models/validations/household_validations_spec.rb

@ -252,18 +252,18 @@ RSpec.describe Validations::HouseholdValidations do
record.hhmemb = 0
household_validator.validate_numeric_min_max(record)
expect(record.errors["hhmemb"])
.to include(match I18n.t("validations.shared.numeric.within_range", field: "Number of household members", min: 1, max: 8))
.to include(match I18n.t("validations.shared.numeric.within_range", field: "Number of household members", min: 1, max: 15))
end
it "validates that the number of household members cannot be more than 8" do
record.hhmemb = 9
it "validates that the number of household members cannot be more than 15" do
record.hhmemb = 16
household_validator.validate_numeric_min_max(record)
expect(record.errors["hhmemb"])
.to include(match I18n.t("validations.shared.numeric.within_range", field: "Number of household members", min: 1, max: 8))
.to include(match I18n.t("validations.shared.numeric.within_range", field: "Number of household members", min: 1, max: 15))
end
it "expects that the number of other household members is between the min and max" do
record.hhmemb = 5
it "expects that the number of household members is between the min and max" do
record.hhmemb = 11
household_validator.validate_numeric_min_max(record)
expect(record.errors["hhmemb"]).to be_empty
end

Loading…
Cancel
Save