diff --git a/spec/models/validations/household_validations_spec.rb b/spec/models/validations/household_validations_spec.rb index 23a7fcb69..caf53695e 100644 --- a/spec/models/validations/household_validations_spec.rb +++ b/spec/models/validations/household_validations_spec.rb @@ -363,7 +363,7 @@ RSpec.describe Validations::HouseholdValidations do end end - it "does not add an error for a person aged 16-19 who is a student but not a child of the buyer" do + it "does not add an error for a person aged 16-19 who is a student but not a child of the lead tenant" do record.age2 = 18 record.ecstat2 = "7" record.relat2 = "P" @@ -373,7 +373,17 @@ RSpec.describe Validations::HouseholdValidations do expect(record.errors["age2"]).to be_empty end - it "adds errors for a person who is a child of the buyer and a student but not aged 16-19" do + it "does not add an error for a person not aged 16-19 who is a student but not a child of the lead tenant" do + record.age2 = 20 + record.ecstat2 = "7" + record.relat2 = "P" + household_validator.validate_household_number_of_other_members(record) + expect(record.errors["relat2"]).to be_empty + expect(record.errors["ecstat2"]).to be_empty + expect(record.errors["age2"]).to be_empty + end + + it "adds errors for a person who is a child of the lead tenant and a student but not aged 16-19" do record.age2 = 14 record.ecstat2 = "7" record.relat2 = "C" diff --git a/spec/models/validations/sales/household_validations_spec.rb b/spec/models/validations/sales/household_validations_spec.rb index 3177cc631..e4ca5ae7f 100644 --- a/spec/models/validations/sales/household_validations_spec.rb +++ b/spec/models/validations/sales/household_validations_spec.rb @@ -117,6 +117,16 @@ RSpec.describe Validations::Sales::HouseholdValidations do expect(record.errors["age2"]).to be_empty end + it "does not add an error for a person not aged 16-19 who is a student but not a child of the buyer" do + record.age2 = 20 + record.ecstat2 = "7" + record.relat2 = "P" + household_validator.validate_household_number_of_other_members(record) + expect(record.errors["relat2"]).to be_empty + expect(record.errors["ecstat2"]).to be_empty + expect(record.errors["age2"]).to be_empty + end + it "adds errors for a person aged 16-19 who is a child of the buyer but not a student" do record.age2 = 17 record.ecstat2 = "1"