Browse Source

feat: improve validate_person_age_matches_economic_status test case coverage

pull/3329/head
Nat Dean-Lewis 4 days ago
parent
commit
4b5adf2a7d
  1. 16
      spec/models/validations/household_validations_spec.rb

16
spec/models/validations/household_validations_spec.rb

@ -270,6 +270,14 @@ RSpec.describe Validations::HouseholdValidations do
end
describe "#validate_person_age_matches_economic_status" do
it "does add errors when the person marked as a child but is not under 16" do
record.age2 = 17
record.ecstat2 = 9
household_validator.validate_person_age_matches_economic_status(record)
expect(record.errors["ecstat2"]).to include(match I18n.t("validations.sales.household.ecstat.child_over_16", person_num: 2))
expect(record.errors["age2"]).to include(match I18n.t("validations.sales.household.age.child_over_16", person_num: 2))
end
it "does not add errors when the person is under 16 but not marked as a child" do
record.age2 = 14
record.ecstat2 = 1
@ -277,6 +285,14 @@ RSpec.describe Validations::HouseholdValidations do
expect(record.errors["ecstat2"]).to be_empty
expect(record.errors["age2"]).to be_empty
end
it "does not add errors when the person is marked as a child and under 16" do
record.age2 = 14
record.ecstat2 = 9
household_validator.validate_person_age_matches_economic_status(record)
expect(record.errors["ecstat2"]).to be_empty
expect(record.errors["age2"]).to be_empty
end
end
describe "condition effects validation" do

Loading…
Cancel
Save