Browse Source

Don't care about the age in gender validation

pull/1458/head
Kat 3 years ago
parent
commit
b295d8bba8
  1. 8
      app/models/validations/soft_validations.rb
  2. 7
      spec/models/validations/soft_validations_spec.rb

8
app/models/validations/soft_validations.rb

@ -53,7 +53,7 @@ module Validations::SoftValidations
end
def no_females_in_a_pregnant_household?
!females_in_the_household? && all_tenants_age_and_gender_information_completed? && preg_occ == 1
!females_in_the_household? && all_tenants_gender_information_completed? && preg_occ == 1
end
def female_in_pregnant_household_in_soft_validation_range?
@ -66,6 +66,12 @@ module Validations::SoftValidations
end
end
def all_tenants_gender_information_completed?
(1..hhmemb).all? do |n|
public_send("sex#{n}").present? && details_known_or_lead_tenant?(n)
end
end
TWO_YEARS_IN_DAYS = 730
TEN_YEARS_IN_DAYS = 3650

7
spec/models/validations/soft_validations_spec.rb

@ -175,6 +175,13 @@ RSpec.describe Validations::SoftValidations do
end
end
context "when there are no female tenants and age of other tenants is unknown" do
it "shows the interruption screen" do
record.update!(sex1: "M", preg_occ: 1, hhmemb: 1, age1_known: 1)
expect(record.no_females_in_a_pregnant_household?).to be true
end
end
context "when female tenants are under 16" do
it "shows the interruption screen" do
record.update!(age2: 14, sex2: "F", preg_occ: 1, hhmemb: 2, details_known_2: 0, age2_known: 0, age1: 18, sex1: "M", age1_known: 0)

Loading…
Cancel
Save