Browse Source

CLDC-3234: Handle nil hhmemb gracefully in soft validations

pull/2301/head
Rachael Booth 2 years ago
parent
commit
0874f81982
  1. 16
      app/models/validations/soft_validations.rb

16
app/models/validations/soft_validations.rb

@ -73,13 +73,17 @@ module Validations::SoftValidations
end end
def all_tenants_age_and_gender_information_completed? def all_tenants_age_and_gender_information_completed?
(1..hhmemb).all? do |n| person_count = hhmemb || 8
(1..person_count).all? do |n|
public_send("sex#{n}").present? && public_send("age#{n}").present? && details_known_or_lead_tenant?(n) && public_send("age#{n}_known").present? && public_send("age#{n}_known").zero? public_send("sex#{n}").present? && public_send("age#{n}").present? && details_known_or_lead_tenant?(n) && public_send("age#{n}_known").present? && public_send("age#{n}_known").zero?
end end
end end
def all_tenants_gender_information_completed? def all_tenants_gender_information_completed?
(1..hhmemb).all? do |n| person_count = hhmemb || 8
(1..person_count).all? do |n|
public_send("sex#{n}").present? && details_known_or_lead_tenant?(n) public_send("sex#{n}").present? && details_known_or_lead_tenant?(n)
end end
end end
@ -197,13 +201,17 @@ private
end end
def females_in_age_range(min, max) def females_in_age_range(min, max)
(1..hhmemb).any? do |n| person_count = hhmemb || 8
(1..person_count).any? do |n|
public_send("sex#{n}") == "F" && public_send("age#{n}").present? && public_send("age#{n}").between?(min, max) public_send("sex#{n}") == "F" && public_send("age#{n}").present? && public_send("age#{n}").between?(min, max)
end end
end end
def females_in_the_household? def females_in_the_household?
(1..hhmemb).any? do |n| person_count = hhmemb || 8
(1..person_count).any? do |n|
public_send("sex#{n}") == "F" || public_send("sex#{n}").nil? public_send("sex#{n}") == "F" || public_send("sex#{n}").nil?
end end
end end

Loading…
Cancel
Save