From 1d077f21d985407bb24699b8baec55f782db984d Mon Sep 17 00:00:00 2001 From: samyou-softwire Date: Tue, 24 Feb 2026 11:14:37 +0000 Subject: [PATCH 1/5] CLDC-4239: Update age range for pregnancy soft validation for 2026 --- app/models/validations/soft_validations.rb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/app/models/validations/soft_validations.rb b/app/models/validations/soft_validations.rb index ea17d0601..0ff08afb1 100644 --- a/app/models/validations/soft_validations.rb +++ b/app/models/validations/soft_validations.rb @@ -76,7 +76,8 @@ module Validations::SoftValidations end def no_household_member_likely_to_be_pregnant? - all_male_tenants_in_a_pregnant_household? || non_males_in_pregnant_household_not_in_pregnancy_range? + # in this 2026 check we used a wider age range + all_male_tenants_in_a_pregnant_household? || non_males_in_pregnant_household_not_in_range?(13, 55) end def all_male_tenants_in_a_pregnant_household? @@ -84,7 +85,7 @@ module Validations::SoftValidations end def non_males_in_pregnant_household_not_in_pregnancy_range? - all_tenants_age_and_gender_information_completed? && non_males_in_the_household? && !any_non_male_in_expected_pregnancy_age_range(16, 50) && preg_occ == 1 + non_males_in_pregnant_household_not_in_range?(16, 50) end TWO_YEARS_IN_DAYS = 730 @@ -252,6 +253,10 @@ private public_send("details_known_#{tenant_number}").zero? end + def non_males_in_pregnant_household_not_in_range?(min, max) + all_tenants_age_and_gender_information_completed? && non_males_in_the_household? && !any_non_male_in_expected_pregnancy_age_range(min, max) && preg_occ == 1 + end + def any_non_male_in_expected_pregnancy_age_range(min, max) person_count = hhmemb || 8 From 1505a84d165ed7545abe8934b2aaa1900b28d5a2 Mon Sep 17 00:00:00 2001 From: samyou-softwire Date: Tue, 24 Feb 2026 11:22:20 +0000 Subject: [PATCH 2/5] CLDC-4239: Update tests looks like the 2026 tests were testing the 2025 method, so have updated --- .../validations/soft_validations_spec.rb | 44 ++++++++++++++----- 1 file changed, 34 insertions(+), 10 deletions(-) diff --git a/spec/models/validations/soft_validations_spec.rb b/spec/models/validations/soft_validations_spec.rb index 9026b03dc..9051a2ecc 100644 --- a/spec/models/validations/soft_validations_spec.rb +++ b/spec/models/validations/soft_validations_spec.rb @@ -298,7 +298,7 @@ RSpec.describe Validations::SoftValidations do end it "shows the interruption screen" do - expect(record.all_male_tenants_in_a_pregnant_household?).to be true + expect(record.no_household_member_likely_to_be_pregnant?).to be true end end @@ -310,7 +310,7 @@ RSpec.describe Validations::SoftValidations do end it "shows the interruption screen" do - expect(record.all_male_tenants_in_a_pregnant_household?).to be true + expect(record.no_household_member_likely_to_be_pregnant?).to be true end end @@ -328,11 +328,23 @@ RSpec.describe Validations::SoftValidations do end it "does not show the interruption screen" do - expect(record.all_male_tenants_in_a_pregnant_household?).to be false + expect(record.no_household_member_likely_to_be_pregnant?).to be false end end context "when female tenants are under 16" do + before do + record.age1 = 15 + record.sexrab1 = "F" + record.gender_same_as_sex1 = 1 + end + + it "does not show the interruption screen" do + expect(record.no_household_member_likely_to_be_pregnant?).to be false + end + end + + context "when female tenants are under 13" do before do record.age1 = 12 record.sexrab1 = "F" @@ -340,11 +352,23 @@ RSpec.describe Validations::SoftValidations do end it "shows the interruption screen" do - expect(record.non_males_in_pregnant_household_not_in_pregnancy_range?).to be true + expect(record.no_household_member_likely_to_be_pregnant?).to be true end end context "when female tenants are over 50" do + before do + record.age1 = 51 + record.sexrab1 = "F" + record.gender_same_as_sex1 = 1 + end + + it "does not show the interruption screen" do + expect(record.no_household_member_likely_to_be_pregnant?).to be false + end + end + + context "when female tenants are over 55" do before do record.age1 = 60 record.sexrab1 = "F" @@ -352,7 +376,7 @@ RSpec.describe Validations::SoftValidations do end it "shows the interruption screen" do - expect(record.non_males_in_pregnant_household_not_in_pregnancy_range?).to be true + expect(record.no_household_member_likely_to_be_pregnant?).to be true end end @@ -365,7 +389,7 @@ RSpec.describe Validations::SoftValidations do end it "shows the interruption screen" do - expect(record.non_males_in_pregnant_household_not_in_pregnancy_range?).to be true + expect(record.no_household_member_likely_to_be_pregnant?).to be true end end @@ -378,7 +402,7 @@ RSpec.describe Validations::SoftValidations do end it "shows the interruption screen" do - expect(record.non_males_in_pregnant_household_not_in_pregnancy_range?).to be true + expect(record.no_household_member_likely_to_be_pregnant?).to be true end end @@ -390,7 +414,7 @@ RSpec.describe Validations::SoftValidations do end it "does not show the interruption screen" do - expect(record.non_males_in_pregnant_household_not_in_pregnancy_range?).to be false + expect(record.no_household_member_likely_to_be_pregnant?).to be false end end @@ -405,7 +429,7 @@ RSpec.describe Validations::SoftValidations do end it "does not show the interruption screen" do - expect(record.non_males_in_pregnant_household_not_in_pregnancy_range?).to be false + expect(record.no_household_member_likely_to_be_pregnant?).to be false end end @@ -423,7 +447,7 @@ RSpec.describe Validations::SoftValidations do end it "does not show the interruption screen" do - expect(record.non_males_in_pregnant_household_not_in_pregnancy_range?).to be false + expect(record.no_household_member_likely_to_be_pregnant?).to be false end end end From 9ce98c500c5544840ca7904537a6b7c64063fb20 Mon Sep 17 00:00:00 2001 From: samyou-softwire Date: Wed, 4 Mar 2026 09:36:26 +0000 Subject: [PATCH 3/5] fixup! CLDC-4239: Update tests --- .../validations/soft_validations_spec.rb | 42 +++++++++++++++---- 1 file changed, 34 insertions(+), 8 deletions(-) diff --git a/spec/models/validations/soft_validations_spec.rb b/spec/models/validations/soft_validations_spec.rb index 9051a2ecc..95500b066 100644 --- a/spec/models/validations/soft_validations_spec.rb +++ b/spec/models/validations/soft_validations_spec.rb @@ -332,9 +332,9 @@ RSpec.describe Validations::SoftValidations do end end - context "when female tenants are under 16" do + context "when female tenants are 13 or over" do before do - record.age1 = 15 + record.age1 = 13 record.sexrab1 = "F" record.gender_same_as_sex1 = 1 end @@ -356,9 +356,9 @@ RSpec.describe Validations::SoftValidations do end end - context "when female tenants are over 50" do + context "when female tenants are 55 or under" do before do - record.age1 = 51 + record.age1 = 55 record.sexrab1 = "F" record.gender_same_as_sex1 = 1 end @@ -370,7 +370,7 @@ RSpec.describe Validations::SoftValidations do context "when female tenants are over 55" do before do - record.age1 = 60 + record.age1 = 56 record.sexrab1 = "F" record.gender_same_as_sex1 = 1 end @@ -380,7 +380,20 @@ RSpec.describe Validations::SoftValidations do end end - context "when non binary tenants are under 16" do + context "when non binary tenants are 13 or over" do + before do + record.age1 = 13 + record.sexrab1 = "M" + record.gender_same_as_sex1 = 2 + record.gender_description1 = "Non-binary" + end + + it "does not show the interruption screen" do + expect(record.no_household_member_likely_to_be_pregnant?).to be false + end + end + + context "when non binary tenants are under 13" do before do record.age1 = 12 record.sexrab1 = "M" @@ -393,9 +406,22 @@ RSpec.describe Validations::SoftValidations do end end - context "when non binary tenants are over 50" do + context "when non binary tenants are 55 or under" do + before do + record.age1 = 55 + record.sexrab1 = "M" + record.gender_same_as_sex1 = 2 + record.gender_description1 = "Non-binary" + end + + it "does not show the interruption screen" do + expect(record.no_household_member_likely_to_be_pregnant?).to be false + end + end + + context "when non binary tenants are over 55" do before do - record.age1 = 60 + record.age1 = 56 record.sexrab1 = "M" record.gender_same_as_sex1 = 2 record.gender_description1 = "Non-binary" From 6a2c7b66d87594fa8d0742d1b3a93ca6b5188d21 Mon Sep 17 00:00:00 2001 From: samyou-softwire Date: Tue, 10 Mar 2026 14:17:36 +0000 Subject: [PATCH 4/5] fixup! CLDC-4239: Update tests add boundary cases for 2025 --- .../validations/soft_validations_spec.rb | 30 ++++++++++++++++--- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/spec/models/validations/soft_validations_spec.rb b/spec/models/validations/soft_validations_spec.rb index 95500b066..aaaa600b7 100644 --- a/spec/models/validations/soft_validations_spec.rb +++ b/spec/models/validations/soft_validations_spec.rb @@ -196,7 +196,7 @@ RSpec.describe Validations::SoftValidations do context "when female tenants are under 16" do it "shows the interruption screen" do - record.age2 = 14 + record.age2 = 15 record.sex2 = "F" record.preg_occ = 1 record.hhmemb = 2 @@ -209,9 +209,20 @@ RSpec.describe Validations::SoftValidations do end end + context "when female tenants are 16 and over" do + it "does not show the interruption screen" do + record.age1 = 16 + record.sex1 = "F" + record.preg_occ = 1 + record.hhmemb = 1 + record.age1_known = 0 + expect(record.non_males_in_pregnant_household_not_in_pregnancy_range?).to be false + end + end + context "when female tenants are over 50" do it "shows the interruption screen" do - record.age1 = 54 + record.age1 = 51 record.sex1 = "F" record.preg_occ = 1 record.hhmemb = 1 @@ -220,9 +231,20 @@ RSpec.describe Validations::SoftValidations do end end + context "when female tenants are 50 or under" do + it "shows the interruption screen" do + record.age1 = 50 + record.sex1 = "F" + record.preg_occ = 1 + record.hhmemb = 1 + record.age1_known = 0 + expect(record.non_males_in_pregnant_household_not_in_pregnancy_range?).to be false + end + end + context "when non-binary tenants are under 16" do it "does not show the interruption screen" do - record.age2 = 14 + record.age2 = 15 record.sex2 = "X" record.preg_occ = 1 record.hhmemb = 2 @@ -237,7 +259,7 @@ RSpec.describe Validations::SoftValidations do context "when non-binary tenants are over 50" do it "does not show the interruption screen" do - record.age1 = 54 + record.age1 = 51 record.sex1 = "X" record.preg_occ = 1 record.hhmemb = 1 From 421a70894dfa8152865656366adf90c8f47ab0c7 Mon Sep 17 00:00:00 2001 From: samyou-softwire Date: Wed, 11 Mar 2026 09:50:44 +0000 Subject: [PATCH 5/5] fixup! CLDC-4239: Update tests make 8 household memmbers clear --- spec/models/validations/soft_validations_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/models/validations/soft_validations_spec.rb b/spec/models/validations/soft_validations_spec.rb index aaaa600b7..4b0ac6711 100644 --- a/spec/models/validations/soft_validations_spec.rb +++ b/spec/models/validations/soft_validations_spec.rb @@ -180,7 +180,7 @@ RSpec.describe Validations::SoftValidations do end end - context "when all tenants are male and household members are over 8" do + context "when all tenants are male and more than 8 household members" do it "does not show the interruption screen" do (1..8).each do |n| record.send("sex#{n}=", "M") @@ -336,7 +336,7 @@ RSpec.describe Validations::SoftValidations do end end - context "when all tenants are male and household members are over 8" do + context "when all tenants are male and more than 8 household members" do before do (1..8).each do |n| record.send("sexrab#{n}=", "M")