Browse Source

CLDC-3576 Update soft pregnancy validation (#2640)

* Update soft pregnancy validation

* Fix tests
pull/2641/head
kosiakkatrina 4 months ago committed by GitHub
parent
commit
d5f2424247
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 4
      app/models/form/lettings/pages/no_females_pregnant_household_lead_age_value_check.rb
  2. 4
      app/models/form/lettings/pages/no_females_pregnant_household_lead_hhmemb_value_check.rb
  3. 4
      app/models/form/lettings/pages/no_females_pregnant_household_lead_value_check.rb
  4. 4
      app/models/form/lettings/pages/no_females_pregnant_household_person_age_value_check.rb
  5. 4
      app/models/form/lettings/pages/no_females_pregnant_household_person_value_check.rb
  6. 4
      app/models/form/lettings/pages/no_females_pregnant_household_value_check.rb
  7. 12
      app/models/validations/soft_validations.rb
  8. 36
      config/forms/2021_2022.json
  9. 36
      config/forms/2022_2023.json
  10. 2
      config/locales/en.yml
  11. 8
      spec/models/form/lettings/pages/no_females_pregnant_household_person_age_value_check_spec.rb
  12. 8
      spec/models/form/lettings/pages/no_females_pregnant_household_person_value_check_spec.rb
  13. 12
      spec/models/validations/soft_validations_spec.rb

4
app/models/form/lettings/pages/no_females_pregnant_household_lead_age_value_check.rb

@ -2,13 +2,13 @@ class Form::Lettings::Pages::NoFemalesPregnantHouseholdLeadAgeValueCheck < ::For
def initialize(id, hsh, subsection)
super(id, hsh, subsection)
@id = "no_females_pregnant_household_lead_age_value_check"
@depends_on = [{ "no_females_in_a_pregnant_household?" => true }]
@depends_on = [{ "all_male_tenants_in_a_pregnant_household?" => true }]
@title_text = {
"translation" => "soft_validations.pregnancy.title",
"arguments" => [{ "key" => "sex1", "label" => true, "i18n_template" => "sex1" }],
}
@informative_text = {
"translation" => "soft_validations.pregnancy.no_females",
"translation" => "soft_validations.pregnancy.all_male_tenants",
"arguments" => [{ "key" => "sex1", "label" => true, "i18n_template" => "sex1" }],
}
end

4
app/models/form/lettings/pages/no_females_pregnant_household_lead_hhmemb_value_check.rb

@ -2,13 +2,13 @@ class Form::Lettings::Pages::NoFemalesPregnantHouseholdLeadHhmembValueCheck < ::
def initialize(id, hsh, subsection)
super
@id = "no_females_pregnant_household_lead_hhmemb_value_check"
@depends_on = [{ "no_females_in_a_pregnant_household?" => true }]
@depends_on = [{ "all_male_tenants_in_a_pregnant_household?" => true }]
@title_text = {
"translation" => "soft_validations.pregnancy.title",
"arguments" => [{ "key" => "sex1", "label" => true, "i18n_template" => "sex1" }],
}
@informative_text = {
"translation" => "soft_validations.pregnancy.no_females",
"translation" => "soft_validations.pregnancy.all_male_tenants",
"arguments" => [{ "key" => "sex1", "label" => true, "i18n_template" => "sex1" }],
}
end

4
app/models/form/lettings/pages/no_females_pregnant_household_lead_value_check.rb

@ -2,13 +2,13 @@ class Form::Lettings::Pages::NoFemalesPregnantHouseholdLeadValueCheck < ::Form::
def initialize(id, hsh, subsection)
super
@id = "no_females_pregnant_household_lead_value_check"
@depends_on = [{ "no_females_in_a_pregnant_household?" => true }]
@depends_on = [{ "all_male_tenants_in_a_pregnant_household?" => true }]
@title_text = {
"translation" => "soft_validations.pregnancy.title",
"arguments" => [{ "key" => "sex1", "label" => true, "i18n_template" => "sex1" }],
}
@informative_text = {
"translation" => "soft_validations.pregnancy.no_females",
"translation" => "soft_validations.pregnancy.all_male_tenants",
"arguments" => [{ "key" => "sex1", "label" => true, "i18n_template" => "sex1" }],
}
end

4
app/models/form/lettings/pages/no_females_pregnant_household_person_age_value_check.rb

@ -2,13 +2,13 @@ class Form::Lettings::Pages::NoFemalesPregnantHouseholdPersonAgeValueCheck < ::F
def initialize(id, hsh, subsection, person_index:)
super(id, hsh, subsection)
@id = "no_females_pregnant_household_person_#{person_index}_age_value_check"
@depends_on = [{ "no_females_in_a_pregnant_household?" => true, "age#{person_index}_known" => 0 }]
@depends_on = [{ "all_male_tenants_in_a_pregnant_household?" => true, "age#{person_index}_known" => 0 }]
@title_text = {
"translation" => "soft_validations.pregnancy.title",
"arguments" => [{ "key" => "sex1", "label" => true, "i18n_template" => "sex1" }],
}
@informative_text = {
"translation" => "soft_validations.pregnancy.no_females",
"translation" => "soft_validations.pregnancy.all_male_tenants",
"arguments" => [{ "key" => "sex1", "label" => true, "i18n_template" => "sex1" }],
}
@person_index = person_index

4
app/models/form/lettings/pages/no_females_pregnant_household_person_value_check.rb

@ -2,13 +2,13 @@ class Form::Lettings::Pages::NoFemalesPregnantHouseholdPersonValueCheck < ::Form
def initialize(id, hsh, subsection, person_index:)
super(id, hsh, subsection)
@id = "no_females_pregnant_household_person_#{person_index}_value_check"
@depends_on = [{ "no_females_in_a_pregnant_household?" => true, "details_known_#{person_index}" => 0 }]
@depends_on = [{ "all_male_tenants_in_a_pregnant_household?" => true, "details_known_#{person_index}" => 0 }]
@title_text = {
"translation" => "soft_validations.pregnancy.title",
"arguments" => [{ "key" => "sex1", "label" => true, "i18n_template" => "sex1" }],
}
@informative_text = {
"translation" => "soft_validations.pregnancy.no_females",
"translation" => "soft_validations.pregnancy.all_male_tenants",
"arguments" => [{ "key" => "sex1", "label" => true, "i18n_template" => "sex1" }],
}
@person_index = person_index

4
app/models/form/lettings/pages/no_females_pregnant_household_value_check.rb

@ -2,13 +2,13 @@ class Form::Lettings::Pages::NoFemalesPregnantHouseholdValueCheck < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "no_females_pregnant_household_value_check"
@depends_on = [{ "no_females_in_a_pregnant_household?" => true }]
@depends_on = [{ "all_male_tenants_in_a_pregnant_household?" => true }]
@title_text = {
"translation" => "soft_validations.pregnancy.title",
"arguments" => [{ "key" => "sex1", "label" => true, "i18n_template" => "sex1" }],
}
@informative_text = {
"translation" => "soft_validations.pregnancy.no_females",
"translation" => "soft_validations.pregnancy.all_male_tenants",
"arguments" => [{ "key" => "sex1", "label" => true, "i18n_template" => "sex1" }],
}
end

12
app/models/validations/soft_validations.rb

@ -67,8 +67,8 @@ module Validations::SoftValidations
end
end
def no_females_in_a_pregnant_household?
!females_in_the_household? && all_tenants_gender_information_completed? && preg_occ == 1
def all_male_tenants_in_a_pregnant_household?
all_male_tenants_in_the_household? && all_tenants_gender_information_completed? && preg_occ == 1
end
def female_in_pregnant_household_in_soft_validation_range?
@ -226,6 +226,14 @@ private
end
end
def all_male_tenants_in_the_household?
person_count = hhmemb || 8
(1..person_count).all? do |n|
public_send("sex#{n}") == "M"
end
end
def tenant_is_retired?(economic_status)
economic_status == 5
end

36
config/forms/2021_2022.json

@ -1170,7 +1170,7 @@
"no_females_pregnant_household_lead_hhmemb_value_check": {
"depends_on": [
{
"no_females_in_a_pregnant_household?": true
"all_male_tenants_in_a_pregnant_household?": true
}
],
"title_text": {
@ -1312,7 +1312,7 @@
"no_females_pregnant_household_lead_age_value_check": {
"depends_on": [
{
"no_females_in_a_pregnant_household?": true
"all_male_tenants_in_a_pregnant_household?": true
}
],
"title_text": {
@ -1433,7 +1433,7 @@
"no_females_pregnant_household_lead_value_check": {
"depends_on": [
{
"no_females_in_a_pregnant_household?": true
"all_male_tenants_in_a_pregnant_household?": true
}
],
"title_text": {
@ -2091,7 +2091,7 @@
"no_females_pregnant_household_person_2_age_value_check": {
"depends_on": [
{
"no_females_in_a_pregnant_household?": true,
"all_male_tenants_in_a_pregnant_household?": true,
"age2_known": 0
}
],
@ -2214,7 +2214,7 @@
"no_females_pregnant_household_person_2_value_check": {
"depends_on": [
{
"no_females_in_a_pregnant_household?": true,
"all_male_tenants_in_a_pregnant_household?": true,
"details_known_2": 0
}
],
@ -2626,7 +2626,7 @@
"no_females_pregnant_household_person_3_age_value_check": {
"depends_on": [
{
"no_females_in_a_pregnant_household?": true,
"all_male_tenants_in_a_pregnant_household?": true,
"age3_known": 0
}
],
@ -2749,7 +2749,7 @@
"no_females_pregnant_household_person_3_value_check": {
"depends_on": [
{
"no_females_in_a_pregnant_household?": true,
"all_male_tenants_in_a_pregnant_household?": true,
"details_known_3": 0
}
],
@ -3158,7 +3158,7 @@
"no_females_pregnant_household_person_4_age_value_check": {
"depends_on": [
{
"no_females_in_a_pregnant_household?": true,
"all_male_tenants_in_a_pregnant_household?": true,
"age4_known": 0
}
],
@ -3281,7 +3281,7 @@
"no_females_pregnant_household_person_4_value_check": {
"depends_on": [
{
"no_females_in_a_pregnant_household?": true,
"all_male_tenants_in_a_pregnant_household?": true,
"details_known_4": 0
}
],
@ -3687,7 +3687,7 @@
"no_females_pregnant_household_person_5_age_value_check": {
"depends_on": [
{
"no_females_in_a_pregnant_household?": true,
"all_male_tenants_in_a_pregnant_household?": true,
"age5_known": 0
}
],
@ -3810,7 +3810,7 @@
"no_females_pregnant_household_person_5_value_check": {
"depends_on": [
{
"no_females_in_a_pregnant_household?": true,
"all_male_tenants_in_a_pregnant_household?": true,
"details_known_5": 0
}
],
@ -4213,7 +4213,7 @@
"no_females_pregnant_household_person_6_age_value_check": {
"depends_on": [
{
"no_females_in_a_pregnant_household?": true,
"all_male_tenants_in_a_pregnant_household?": true,
"age6_known": 0
}
],
@ -4336,7 +4336,7 @@
"no_females_pregnant_household_person_6_value_check": {
"depends_on": [
{
"no_females_in_a_pregnant_household?": true,
"all_male_tenants_in_a_pregnant_household?": true,
"details_known_6": 0
}
],
@ -4736,7 +4736,7 @@
"no_females_pregnant_household_person_7_age_value_check": {
"depends_on": [
{
"no_females_in_a_pregnant_household?": true,
"all_male_tenants_in_a_pregnant_household?": true,
"age7_known": 0
}
],
@ -4859,7 +4859,7 @@
"no_females_pregnant_household_person_7_value_check": {
"depends_on": [
{
"no_females_in_a_pregnant_household?": true,
"all_male_tenants_in_a_pregnant_household?": true,
"details_known_7": 0
}
],
@ -5256,7 +5256,7 @@
"no_females_pregnant_household_person_8_age_value_check": {
"depends_on": [
{
"no_females_in_a_pregnant_household?": true,
"all_male_tenants_in_a_pregnant_household?": true,
"age8_known": 0
}
],
@ -5379,7 +5379,7 @@
"no_females_pregnant_household_person_8_value_check": {
"depends_on": [
{
"no_females_in_a_pregnant_household?": true,
"all_male_tenants_in_a_pregnant_household?": true,
"details_known_8": 0
}
],
@ -5794,7 +5794,7 @@
"no_females_pregnant_household_value_check": {
"depends_on": [
{
"no_females_in_a_pregnant_household?": true
"all_male_tenants_in_a_pregnant_household?": true
}
],
"title_text": {

36
config/forms/2022_2023.json

@ -1200,7 +1200,7 @@
"no_females_pregnant_household_lead_hhmemb_value_check": {
"depends_on": [
{
"no_females_in_a_pregnant_household?": true
"all_male_tenants_in_a_pregnant_household?": true
}
],
"title_text": {
@ -1372,7 +1372,7 @@
"no_females_pregnant_household_lead_age_value_check": {
"depends_on": [
{
"no_females_in_a_pregnant_household?": true
"all_male_tenants_in_a_pregnant_household?": true
}
],
"title_text": {
@ -1523,7 +1523,7 @@
"no_females_pregnant_household_lead_value_check": {
"depends_on": [
{
"no_females_in_a_pregnant_household?": true
"all_male_tenants_in_a_pregnant_household?": true
}
],
"title_text": {
@ -2163,7 +2163,7 @@
"no_females_pregnant_household_person_2_age_value_check": {
"depends_on": [
{
"no_females_in_a_pregnant_household?": true,
"all_male_tenants_in_a_pregnant_household?": true,
"age2_known": 0
}
],
@ -2316,7 +2316,7 @@
"no_females_pregnant_household_person_2_value_check": {
"depends_on": [
{
"no_females_in_a_pregnant_household?": true,
"all_male_tenants_in_a_pregnant_household?": true,
"details_known_2": 0
}
],
@ -2746,7 +2746,7 @@
"no_females_pregnant_household_person_3_age_value_check": {
"depends_on": [
{
"no_females_in_a_pregnant_household?": true,
"all_male_tenants_in_a_pregnant_household?": true,
"age3_known": 0
}
],
@ -2899,7 +2899,7 @@
"no_females_pregnant_household_person_3_value_check": {
"depends_on": [
{
"no_females_in_a_pregnant_household?": true,
"all_male_tenants_in_a_pregnant_household?": true,
"details_known_3": 0
}
],
@ -3326,7 +3326,7 @@
"no_females_pregnant_household_person_4_age_value_check": {
"depends_on": [
{
"no_females_in_a_pregnant_household?": true,
"all_male_tenants_in_a_pregnant_household?": true,
"age4_known": 0
}
],
@ -3479,7 +3479,7 @@
"no_females_pregnant_household_person_4_value_check": {
"depends_on": [
{
"no_females_in_a_pregnant_household?": true,
"all_male_tenants_in_a_pregnant_household?": true,
"details_known_4": 0
}
],
@ -3903,7 +3903,7 @@
"no_females_pregnant_household_person_5_age_value_check": {
"depends_on": [
{
"no_females_in_a_pregnant_household?": true,
"all_male_tenants_in_a_pregnant_household?": true,
"age5_known": 0
}
],
@ -4056,7 +4056,7 @@
"no_females_pregnant_household_person_5_value_check": {
"depends_on": [
{
"no_females_in_a_pregnant_household?": true,
"all_male_tenants_in_a_pregnant_household?": true,
"details_known_5": 0
}
],
@ -4477,7 +4477,7 @@
"no_females_pregnant_household_person_6_age_value_check": {
"depends_on": [
{
"no_females_in_a_pregnant_household?": true,
"all_male_tenants_in_a_pregnant_household?": true,
"age6_known": 0
}
],
@ -4630,7 +4630,7 @@
"no_females_pregnant_household_person_6_value_check": {
"depends_on": [
{
"no_females_in_a_pregnant_household?": true,
"all_male_tenants_in_a_pregnant_household?": true,
"details_known_6": 0
}
],
@ -5048,7 +5048,7 @@
"no_females_pregnant_household_person_7_age_value_check": {
"depends_on": [
{
"no_females_in_a_pregnant_household?": true,
"all_male_tenants_in_a_pregnant_household?": true,
"age7_known": 0
}
],
@ -5201,7 +5201,7 @@
"no_females_pregnant_household_person_7_value_check": {
"depends_on": [
{
"no_females_in_a_pregnant_household?": true,
"all_male_tenants_in_a_pregnant_household?": true,
"details_known_7": 0
}
],
@ -5616,7 +5616,7 @@
"no_females_pregnant_household_person_8_age_value_check": {
"depends_on": [
{
"no_females_in_a_pregnant_household?": true,
"all_male_tenants_in_a_pregnant_household?": true,
"age8_known": 0
}
],
@ -5769,7 +5769,7 @@
"no_females_pregnant_household_person_8_value_check": {
"depends_on": [
{
"no_females_in_a_pregnant_household?": true,
"all_male_tenants_in_a_pregnant_household?": true,
"details_known_8": 0
}
],
@ -6205,7 +6205,7 @@
"no_females_pregnant_household_value_check": {
"depends_on": [
{
"no_females_in_a_pregnant_household?": true
"all_male_tenants_in_a_pregnant_household?": true
}
],
"title_text": {

2
config/locales/en.yml

@ -723,7 +723,7 @@ Make sure these answers are correct."
hint_text: "This is higher than the purchase price minus the discount."
pregnancy:
title: "You told us somebody in the household is pregnant"
no_females: "You also told us there are no female tenants living at the property."
all_male_tenants: "You also told us that all the tenants living at the property are male."
females_not_in_soft_age_range: "You also told us that any female tenants living at the property are in the following age ranges:<ul><li>under 16 years old</li><li>over 50 years old</li></ul>"
major_repairs_date:
title_text: "You told us the property has been vacant for 2 years."

8
spec/models/form/lettings/pages/no_females_pregnant_household_person_age_value_check_spec.rb

@ -33,7 +33,7 @@ RSpec.describe Form::Lettings::Pages::NoFemalesPregnantHouseholdPersonAgeValueCh
[
{
"age2_known" => 0,
"no_females_in_a_pregnant_household?" => true,
"all_male_tenants_in_a_pregnant_household?" => true,
},
],
)
@ -54,7 +54,7 @@ RSpec.describe Form::Lettings::Pages::NoFemalesPregnantHouseholdPersonAgeValueCh
it "has the correct informative_text" do
expect(page.informative_text).to eq({
"translation" => "soft_validations.pregnancy.no_females",
"translation" => "soft_validations.pregnancy.all_male_tenants",
"arguments" => [
{
"key" => "sex1",
@ -78,7 +78,7 @@ RSpec.describe Form::Lettings::Pages::NoFemalesPregnantHouseholdPersonAgeValueCh
[
{
"age3_known" => 0,
"no_females_in_a_pregnant_household?" => true,
"all_male_tenants_in_a_pregnant_household?" => true,
},
],
)
@ -99,7 +99,7 @@ RSpec.describe Form::Lettings::Pages::NoFemalesPregnantHouseholdPersonAgeValueCh
it "has the correct informative_text" do
expect(page.informative_text).to eq({
"translation" => "soft_validations.pregnancy.no_females",
"translation" => "soft_validations.pregnancy.all_male_tenants",
"arguments" => [
{
"key" => "sex1",

8
spec/models/form/lettings/pages/no_females_pregnant_household_person_value_check_spec.rb

@ -33,7 +33,7 @@ RSpec.describe Form::Lettings::Pages::NoFemalesPregnantHouseholdPersonValueCheck
[
{
"details_known_2" => 0,
"no_females_in_a_pregnant_household?" => true,
"all_male_tenants_in_a_pregnant_household?" => true,
},
],
)
@ -54,7 +54,7 @@ RSpec.describe Form::Lettings::Pages::NoFemalesPregnantHouseholdPersonValueCheck
it "has the correct informative_text" do
expect(page.informative_text).to eq({
"translation" => "soft_validations.pregnancy.no_females",
"translation" => "soft_validations.pregnancy.all_male_tenants",
"arguments" => [
{
"key" => "sex1",
@ -78,7 +78,7 @@ RSpec.describe Form::Lettings::Pages::NoFemalesPregnantHouseholdPersonValueCheck
[
{
"details_known_3" => 0,
"no_females_in_a_pregnant_household?" => true,
"all_male_tenants_in_a_pregnant_household?" => true,
},
],
)
@ -99,7 +99,7 @@ RSpec.describe Form::Lettings::Pages::NoFemalesPregnantHouseholdPersonValueCheck
it "has the correct informative_text" do
expect(page.informative_text).to eq({
"translation" => "soft_validations.pregnancy.no_females",
"translation" => "soft_validations.pregnancy.all_male_tenants",
"arguments" => [
{
"key" => "sex1",

12
spec/models/validations/soft_validations_spec.rb

@ -153,24 +153,24 @@ RSpec.describe Validations::SoftValidations do
end
describe "pregnancy soft validations" do
context "when there are no female tenants" do
context "when all tenants are male" do
it "shows the interruption screen" do
record.age1 = 43
record.sex1 = "M"
record.preg_occ = 1
record.hhmemb = 1
record.age1_known = 0
expect(record.no_females_in_a_pregnant_household?).to be true
expect(record.all_male_tenants_in_a_pregnant_household?).to be true
end
end
context "when there are no female tenants and age of other tenants is unknown" do
context "when there all tenants are male and age of tenants is unknown" do
it "shows the interruption screen" do
record.sex1 = "M"
record.preg_occ = 1
record.hhmemb = 1
record.age1_known = 1
expect(record.no_females_in_a_pregnant_household?).to be true
expect(record.all_male_tenants_in_a_pregnant_household?).to be true
end
end
@ -206,7 +206,7 @@ RSpec.describe Validations::SoftValidations do
record.sex1 = "F"
record.preg_occ = 1
record.hhmemb = 1
expect(record.no_females_in_a_pregnant_household?).to be false
expect(record.all_male_tenants_in_a_pregnant_household?).to be false
expect(record.female_in_pregnant_household_in_soft_validation_range?).to be false
end
end
@ -215,7 +215,7 @@ RSpec.describe Validations::SoftValidations do
it "does not show the interruption screen" do
record.preg_occ = 1
record.hhmemb = 2
expect(record.no_females_in_a_pregnant_household?).to be false
expect(record.all_male_tenants_in_a_pregnant_household?).to be false
expect(record.female_in_pregnant_household_in_soft_validation_range?).to be false
end
end

Loading…
Cancel
Save