diff --git a/app/models/form/lettings/pages/person_known.rb b/app/models/form/lettings/pages/person_known.rb index 6e699926d..ec98bde9b 100644 --- a/app/models/form/lettings/pages/person_known.rb +++ b/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 diff --git a/spec/models/validations/household_validations_spec.rb b/spec/models/validations/household_validations_spec.rb index 9848afd67..0f874dcc5 100644 --- a/spec/models/validations/household_validations_spec.rb +++ b/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