Browse Source

CLDC-4143: Add 2026 tests

CLDC-4143-update-gender-validations
Samuel Young 2 days ago
parent
commit
41b2b00003
  1. 330
      spec/models/validations/soft_validations_spec.rb

330
spec/models/validations/soft_validations_spec.rb

@ -1,8 +1,11 @@
require "rails_helper" require "rails_helper"
RSpec.describe Validations::SoftValidations do RSpec.describe Validations::SoftValidations do
let(:organisation) { FactoryBot.build(:organisation, provider_type: "PRP", id: 123) } include CollectionTimeHelper
let(:record) { FactoryBot.build(:lettings_log, owning_organisation: organisation) }
let(:organisation) { build(:organisation, provider_type: "PRP", id: 123) }
let(:start_year) { current_collection_start_year }
let(:record) { build(:lettings_log, owning_organisation: organisation, startdate: collection_start_date_for_year(start_year)) }
describe "rent min max validations" do describe "rent min max validations" do
before do before do
@ -153,98 +156,275 @@ RSpec.describe Validations::SoftValidations do
end end
describe "pregnancy soft validations" do describe "pregnancy soft validations" do
context "when all tenants are male" do context "when 2025" do
it "shows the interruption screen" do let(:start_year) { 2025 }
record.age1 = 43
record.sex1 = "M" context "when all tenants are male" do
record.preg_occ = 1 it "shows the interruption screen" do
record.hhmemb = 1 record.age1 = 43
record.age1_known = 0 record.sex1 = "M"
expect(record.all_male_tenants_in_a_pregnant_household?).to be true record.preg_occ = 1
record.hhmemb = 1
record.age1_known = 0
expect(record.all_male_tenants_in_a_pregnant_household?).to be true
end
end end
end
context "when there all tenants are male and age of tenants is unknown" do context "when there all tenants are male and age of tenants is unknown" do
it "shows the interruption screen" do it "shows the interruption screen" do
record.sex1 = "M" record.sex1 = "M"
record.preg_occ = 1 record.preg_occ = 1
record.hhmemb = 1 record.hhmemb = 1
record.age1_known = 1 record.age1_known = 1
expect(record.all_male_tenants_in_a_pregnant_household?).to be true expect(record.all_male_tenants_in_a_pregnant_household?).to be true
end
end end
end
context "when all tenants are male and household members are over 8" do context "when all tenants are male and household members are over 8" do
it "does not show the interruption screen" do it "does not show the interruption screen" do
(1..8).each do |n| (1..8).each do |n|
record.send("sex#{n}=", "M") record.send("sex#{n}=", "M")
record.send("age#{n}=", 30) record.send("age#{n}=", 30)
record.send("age#{n}_known=", 0) record.send("age#{n}_known=", 0)
record.send("details_known_#{n}=", 0) unless n == 1 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
record.preg_occ = 1
record.hhmemb = 9
expect(record.all_male_tenants_in_a_pregnant_household?).to be false
end 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
record.sex2 = "F" record.sex2 = "F"
record.preg_occ = 1 record.preg_occ = 1
record.hhmemb = 2 record.hhmemb = 2
record.details_known_2 = 0 record.details_known_2 = 0
record.age2_known = 0 record.age2_known = 0
record.age1 = 18 record.age1 = 18
record.sex1 = "M" record.sex1 = "M"
record.age1_known = 0 record.age1_known = 0
expect(record.non_males_in_pregnant_household_in_soft_validation_range?).to be true expect(record.non_males_in_pregnant_household_in_soft_validation_range?).to be true
end
end end
end
context "when female tenants are over 50" do context "when female tenants are over 50" do
it "shows the interruption screen" do it "shows the interruption screen" do
record.age1 = 54 record.age1 = 54
record.sex1 = "F" record.sex1 = "F"
record.preg_occ = 1 record.preg_occ = 1
record.hhmemb = 1 record.hhmemb = 1
record.age1_known = 0 record.age1_known = 0
expect(record.non_males_in_pregnant_household_in_soft_validation_range?).to be true expect(record.non_males_in_pregnant_household_in_soft_validation_range?).to be true
end
end
context "when non-binary tenants are under 16" do
it "does not show the interruption screen" do
record.age2 = 14
record.sex2 = "X"
record.preg_occ = 1
record.hhmemb = 2
record.details_known_2 = 0
record.age2_known = 0
record.age1 = 18
record.sex1 = "M"
record.age1_known = 0
expect(record.non_males_in_pregnant_household_in_soft_validation_range?).to be false
end
end
context "when non-binary tenants are over 50" do
it "does not show the interruption screen" do
record.age1 = 54
record.sex1 = "X"
record.preg_occ = 1
record.hhmemb = 1
record.age1_known = 0
expect(record.non_males_in_pregnant_household_in_soft_validation_range?).to be false
end
end
context "when female tenants are outside of soft validation ranges" do
it "does not show the interruption screen" do
record.age1 = 44
record.sex1 = "F"
record.preg_occ = 1
record.hhmemb = 1
expect(record.all_male_tenants_in_a_pregnant_household?).to be false
expect(record.non_males_in_pregnant_household_in_soft_validation_range?).to be false
end
end
context "when the information about the tenants is not given" do
it "does not show the interruption screen" do
record.preg_occ = 1
record.hhmemb = 2
expect(record.all_male_tenants_in_a_pregnant_household?).to be false
expect(record.non_males_in_pregnant_household_in_soft_validation_range?).to be false
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.non_males_in_pregnant_household_in_soft_validation_range?).to be false
end
end end
end end
context "when female tenants are outside of soft validation ranges" do context "when 2026" do
it "does not show the interruption screen" do let(:start_year) { 2026 }
record.age1 = 44
record.sex1 = "F" before do
record.age1 = 43
record.age1_known = 0
record.preg_occ = 1 record.preg_occ = 1
record.hhmemb = 1 record.hhmemb = 1
expect(record.all_male_tenants_in_a_pregnant_household?).to be false
expect(record.non_males_in_pregnant_household_in_soft_validation_range?).to be false
end end
end
context "when the information about the tenants is not given" do context "when all tenants are male" do
it "does not show the interruption screen" do before do
record.preg_occ = 1 record.sexrab1 = "M"
record.hhmemb = 2 record.gender_same_as_sex1 = 1
expect(record.all_male_tenants_in_a_pregnant_household?).to be false end
expect(record.non_males_in_pregnant_household_in_soft_validation_range?).to be false
it "shows the interruption screen" do
expect(record.all_male_tenants_in_a_pregnant_household?).to be true
end
end end
end
context "when number of household members is over 8" do context "when there all tenants are male and age of tenants is unknown" do
it "does not show the interruption screen" do before do
(1..8).each do |n| record.sexrab1 = "M"
record.send("sex#{n}=", "F") record.gender_same_as_sex1 = 1
record.send("age#{n}=", 50) record.age1_known = 1
record.send("age#{n}_known=", 0) end
record.send("details_known_#{n}=", 0) unless n == 1
it "shows the interruption screen" do
expect(record.all_male_tenants_in_a_pregnant_household?).to be true
end
end
context "when all tenants are male and household members are over 8" do
before do
(1..8).each do |n|
record.send("sexrab#{n}=", "M")
record.send("gender_same_as_sex#{n}=", 1)
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
end
it "does not show the interruption screen" do
expect(record.all_male_tenants_in_a_pregnant_household?).to be false
end
end
context "when female tenants are under 16" do
before do
record.age1 = 12
record.sexrab1 = "F"
record.gender_same_as_sex1 = 1
end
it "shows the interruption screen" do
expect(record.non_males_in_pregnant_household_in_soft_validation_range?).to be true
end
end
context "when female tenants are over 50" do
before do
record.age1 = 60
record.sexrab1 = "F"
record.gender_same_as_sex1 = 1
end
it "shows the interruption screen" do
expect(record.non_males_in_pregnant_household_in_soft_validation_range?).to be true
end
end
context "when non binary tenants are under 16" do
before do
record.age1 = 12
record.sexrab1 = "M"
record.gender_same_as_sex1 = 2
record.gender_description1 = "Non-binary"
end
it "shows the interruption screen" do
expect(record.non_males_in_pregnant_household_in_soft_validation_range?).to be true
end
end
context "when non binary tenants are over 50" do
before do
record.age1 = 60
record.sexrab1 = "M"
record.gender_same_as_sex1 = 2
record.gender_description1 = "Non-binary"
end
it "shows the interruption screen" do
expect(record.non_males_in_pregnant_household_in_soft_validation_range?).to be true
end
end
context "when female tenants are outside of soft validation ranges" do
before do
record.age1 = 30
record.sexrab1 = "F"
record.gender_same_as_sex1 = 1
end
it "does not show the interruption screen" do
expect(record.non_males_in_pregnant_household_in_soft_validation_range?).to be false
end
end
context "when the information about the tenants is not given" do
before do
record.age1 = nil
record.age1_known = nil
record.sexrab1 = nil
record.gender_same_as_sex1 = nil
record.preg_occ = 1
record.hhmemb = 1
end
it "does not show the interruption screen" do
expect(record.non_males_in_pregnant_household_in_soft_validation_range?).to be false
end
end
context "when number of household members is over 8" do
before do
(1..8).each do |n|
record.send("sexrab#{n}=", "F")
record.send("gender_same_as_sex#{n}=", 1)
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
end
it "does not show the interruption screen" do
expect(record.non_males_in_pregnant_household_in_soft_validation_range?).to be false
end end
record.preg_occ = 1
record.hhmemb = 9
expect(record.non_males_in_pregnant_household_in_soft_validation_range?).to be false
end end
end end
end end

Loading…
Cancel
Save