Browse Source

Do not run pregnancy validations if hhmemb is over 8 (#2869)

pull/2872/head
kosiakkatrina 1 week ago committed by GitHub
parent
commit
456d1e6586
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 4
      app/models/validations/soft_validations.rb
  2. 28
      spec/models/validations/soft_validations_spec.rb

4
app/models/validations/soft_validations.rb

@ -84,6 +84,8 @@ module Validations::SoftValidations
end end
def all_tenants_age_and_gender_information_completed? def all_tenants_age_and_gender_information_completed?
return false if hhmemb.present? && hhmemb > 8
person_count = hhmemb || 8 person_count = hhmemb || 8
(1..person_count).all? do |n| (1..person_count).all? do |n|
@ -235,6 +237,8 @@ private
end end
def all_male_tenants_in_the_household? def all_male_tenants_in_the_household?
return false if hhmemb.present? && hhmemb > 8
person_count = hhmemb || 8 person_count = hhmemb || 8
(1..person_count).all? do |n| (1..person_count).all? do |n|

28
spec/models/validations/soft_validations_spec.rb

@ -174,6 +174,20 @@ RSpec.describe Validations::SoftValidations do
end end
end end
context "when all tenants are male and household members are over 8" do
it "does not show the interruption screen" do
(1..8).each do |n|
record.send("sex#{n}=", "M")
record.send("age#{n}=", 30)
record.send("age#{n}_known=", 0)
record.send("details_known_#{n}=", 0) unless n == 1
end
record.preg_occ = 1
record.hhmemb = 9
expect(record.all_male_tenants_in_a_pregnant_household?).to be false
end
end
context "when female tenants are under 16" do context "when female tenants are under 16" do
it "shows the interruption screen" do it "shows the interruption screen" do
record.age2 = 14 record.age2 = 14
@ -219,6 +233,20 @@ RSpec.describe Validations::SoftValidations do
expect(record.female_in_pregnant_household_in_soft_validation_range?).to be false expect(record.female_in_pregnant_household_in_soft_validation_range?).to be false
end end
end end
context "when number of household members is over 8" do
it "does not show the interruption screen" do
(1..8).each do |n|
record.send("sex#{n}=", "F")
record.send("age#{n}=", 50)
record.send("age#{n}_known=", 0)
record.send("details_known_#{n}=", 0) unless n == 1
end
record.preg_occ = 1
record.hhmemb = 9
expect(record.female_in_pregnant_household_in_soft_validation_range?).to be false
end
end
end end
describe "major repairs date soft validations" do describe "major repairs date soft validations" do

Loading…
Cancel
Save