Browse Source

feat: add tests

pull/1682/head
natdeanlewissoftwire 3 years ago
parent
commit
0e32951ec5
  1. 23
      spec/models/validations/household_validations_spec.rb
  2. 2
      spec/models/validations/sales/household_validations_spec.rb

23
spec/models/validations/household_validations_spec.rb

@ -363,6 +363,29 @@ RSpec.describe Validations::HouseholdValidations do
end end
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
record.age2 = 18
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 buyer and a student but not aged 16-19" do
record.age2 = 14
record.ecstat2 = "7"
record.relat2 = "C"
household_validator.validate_household_number_of_other_members(record)
expect(record.errors["relat2"])
.to include(match I18n.t("validations.household.relat.student_16_19.cannot_be_child.student_not_16_19"))
expect(record.errors["age2"])
.to include(match I18n.t("validations.household.age.student_16_19.must_be_16_19"))
expect(record.errors["ecstat2"])
.to include(match I18n.t("validations.household.ecstat.student_16_19.cannot_be_student.child_not_16_19"))
end
context "when the household contains a person over 70" do context "when the household contains a person over 70" do
it "expects that person under 70 does not need to be retired" do it "expects that person under 70 does not need to be retired" do
record.age2 = 50 record.age2 = 50

2
spec/models/validations/sales/household_validations_spec.rb

@ -107,7 +107,7 @@ RSpec.describe Validations::Sales::HouseholdValidations do
.to include(match I18n.t("validations.household.age.child_over_20")) .to include(match I18n.t("validations.household.age.child_over_20"))
end end
it "does not add and 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 buyer" do
record.age2 = 18 record.age2 = 18
record.ecstat2 = "7" record.ecstat2 = "7"
record.relat2 = "P" record.relat2 = "P"

Loading…
Cancel
Save