From c85c3fff05ef316bca5659ed65ccb74a67f29211 Mon Sep 17 00:00:00 2001 From: Kat Date: Tue, 12 Mar 2024 10:15:00 +0000 Subject: [PATCH] Undo some 2024 validations --- .../validations/household_validations.rb | 49 ++----- .../sales/household_validations.rb | 51 +++---- config/locales/en.yml | 7 - .../validations/household_validations_spec.rb | 128 ++---------------- .../sales/household_validations_spec.rb | 71 +++------- 5 files changed, 58 insertions(+), 248 deletions(-) diff --git a/app/models/validations/household_validations.rb b/app/models/validations/household_validations.rb index df9b1a6ed..90569a8ee 100644 --- a/app/models/validations/household_validations.rb +++ b/app/models/validations/household_validations.rb @@ -88,6 +88,8 @@ module Validations::HouseholdValidations end def validate_person_age_matches_relationship(record) + return unless record.startdate && !record.form.start_year_after_2024? + (2..8).each do |person_num| age = record.public_send("age#{person_num}") relationship = record.public_send("relat#{person_num}") @@ -97,15 +99,12 @@ module Validations::HouseholdValidations record.errors.add "relat#{person_num}", I18n.t("validations.household.relat.child_under_16_lettings", person_num:) record.errors.add "age#{person_num}", I18n.t("validations.household.age.child_under_16_relat_lettings", person_num:) end - - if record.form.start_year_after_2024? && (age > 19 && tenant_is_child?(relationship)) - record.errors.add "relat#{person_num}", I18n.t("validations.household.relat.child_over_19", person_num:) - record.errors.add "age#{person_num}", I18n.t("validations.household.age.child_over_19_relat", person_num:, person: "lead tenant") - end end end def validate_person_age_and_relationship_matches_economic_status(record) + return unless record.startdate && !record.form.start_year_after_2024? + (2..8).each do |person_num| age = record.public_send("age#{person_num}") economic_status = record.public_send("ecstat#{person_num}") @@ -118,46 +117,16 @@ module Validations::HouseholdValidations child = tenant_is_child?(relationship) if age_between_16_19 && !(student || economic_status_refused) && child - if record.form.start_year_after_2024? - record.errors.add "ecstat#{person_num}", I18n.t("validations.household.ecstat.student_16_19.must_be_student_2024", person_num:, person: "lead tenant") - else - record.errors.add "ecstat#{person_num}", I18n.t("validations.household.ecstat.student_16_19.must_be_student") - end + record.errors.add "ecstat#{person_num}", I18n.t("validations.household.ecstat.student_16_19.must_be_student") record.errors.add "age#{person_num}", I18n.t("validations.household.age.student_16_19.cannot_be_16_19.child_not_student") record.errors.add "relat#{person_num}", I18n.t("validations.household.relat.student_16_19.cannot_be_child.16_19_not_student") end - if !age_between_16_19 && student && child - if record.form.start_year_after_2024? - record.errors.add "age#{person_num}", I18n.t("validations.household.age.student_16_19.must_be_16_19_2024", person_num:, person: "lead tenant") - else - record.errors.add "age#{person_num}", I18n.t("validations.household.age.student_16_19.must_be_16_19") - end - record.errors.add "ecstat#{person_num}", I18n.t("validations.household.ecstat.student_16_19.cannot_be_student.child_not_16_19") - record.errors.add "relat#{person_num}", I18n.t("validations.household.relat.student_16_19.cannot_be_child.student_not_16_19") - end - - next unless student && age_between_16_19 && !child && record.form.start_year_after_2024? - - record.errors.add "relat#{person_num}", I18n.t("validations.household.relat.student_16_19.must_be_child_2024", person_num:, person: "lead tenant") - record.errors.add "age#{person_num}", I18n.t("validations.household.age.student_not_child.cannot_be_16_19") - record.errors.add "ecstat#{person_num}", I18n.t("validations.household.ecstat.not_child_16_19.cannot_be_student") - end - end - - def validate_child_12_years_younger(record) - return unless record.form.start_year_after_2024? - - (2..8).each do |person_num| - age = record.public_send("age#{person_num}") - relationship = record.public_send("relat#{person_num}") - next unless age && record.age1 && relationship - - next unless age > record.age1 - 12 && tenant_is_child?(relationship) + next unless !age_between_16_19 && student && child - record.errors.add "age1", I18n.t("validations.household.age.age1_child_12_years_younger_2024", person_num:, person: "lead tenant") - record.errors.add "age#{person_num}", I18n.t("validations.household.age.child_12_years_younger_2024", person_num:, person: "lead tenant") - record.errors.add "relat#{person_num}", I18n.t("validations.household.relat.child_12_years_younger_2024", person_num:, person: "lead tenant") + record.errors.add "age#{person_num}", I18n.t("validations.household.age.student_16_19.must_be_16_19") + record.errors.add "ecstat#{person_num}", I18n.t("validations.household.ecstat.student_16_19.cannot_be_student.child_not_16_19") + record.errors.add "relat#{person_num}", I18n.t("validations.household.relat.student_16_19.cannot_be_child.student_not_16_19") end end diff --git a/app/models/validations/sales/household_validations.rb b/app/models/validations/sales/household_validations.rb index af74865e6..3db3fb85f 100644 --- a/app/models/validations/sales/household_validations.rb +++ b/app/models/validations/sales/household_validations.rb @@ -26,6 +26,8 @@ module Validations::Sales::HouseholdValidations end def validate_person_age_matches_relationship(record) + return unless record.saledate && !record.form.start_year_after_2024? + (2..6).each do |person_num| age = record.public_send("age#{person_num}") relationship = record.public_send("relat#{person_num}") @@ -35,18 +37,15 @@ module Validations::Sales::HouseholdValidations record.errors.add "age#{person_num}", I18n.t("validations.household.age.child_under_16_relat_sales", person_num:) record.errors.add "relat#{person_num}", I18n.t("validations.household.relat.child_under_16_sales", person_num:) elsif age >= 20 && person_is_child?(relationship) - if record.form.start_year_after_2024? - record.errors.add "relat#{person_num}", I18n.t("validations.household.relat.child_over_19", person_num:) - record.errors.add "age#{person_num}", I18n.t("validations.household.age.child_over_19_relat", person_num:, person: "buyer") - else - record.errors.add "age#{person_num}", I18n.t("validations.household.age.child_over_20") - record.errors.add "relat#{person_num}", I18n.t("validations.household.relat.child_over_20") - end + record.errors.add "age#{person_num}", I18n.t("validations.household.age.child_over_20") + record.errors.add "relat#{person_num}", I18n.t("validations.household.relat.child_over_20") end end end def validate_person_age_and_relationship_matches_economic_status(record) + return unless record.saledate && !record.form.start_year_after_2024? + (2..6).each do |person_num| age = record.public_send("age#{person_num}") economic_status = record.public_send("ecstat#{person_num}") @@ -59,30 +58,16 @@ module Validations::Sales::HouseholdValidations child = person_is_child?(relationship) if age_between_16_19 && !(student || economic_status_refused) && child - if record.form.start_year_after_2024? - record.errors.add "ecstat#{person_num}", I18n.t("validations.household.ecstat.student_16_19.must_be_student_2024", person_num:, person: "buyer") - else - record.errors.add "ecstat#{person_num}", I18n.t("validations.household.ecstat.student_16_19.must_be_student") - end + record.errors.add "ecstat#{person_num}", I18n.t("validations.household.ecstat.student_16_19.must_be_student") record.errors.add "age#{person_num}", I18n.t("validations.household.age.student_16_19.cannot_be_16_19.child_not_student") record.errors.add "relat#{person_num}", I18n.t("validations.household.relat.student_16_19.cannot_be_child.16_19_not_student") end - if !age_between_16_19 && student && child - if record.form.start_year_after_2024? - record.errors.add "age#{person_num}", I18n.t("validations.household.age.student_16_19.must_be_16_19_2024", person_num:, person: "buyer") - else - record.errors.add "age#{person_num}", I18n.t("validations.household.age.student_16_19.must_be_16_19") - end - record.errors.add "ecstat#{person_num}", I18n.t("validations.household.ecstat.student_16_19.cannot_be_student.child_not_16_19") - record.errors.add "relat#{person_num}", I18n.t("validations.household.relat.student_16_19.cannot_be_child.student_not_16_19") - end - - next unless student && age_between_16_19 && !child && record.form.start_year_after_2024? + next unless !age_between_16_19 && student && child - record.errors.add "relat#{person_num}", I18n.t("validations.household.relat.student_16_19.must_be_child_2024", person_num:, person: "buyer") - record.errors.add "age#{person_num}", I18n.t("validations.household.age.student_not_child.cannot_be_16_19") - record.errors.add "ecstat#{person_num}", I18n.t("validations.household.ecstat.not_child_16_19.cannot_be_student") + record.errors.add "age#{person_num}", I18n.t("validations.household.age.student_16_19.must_be_16_19") + record.errors.add "ecstat#{person_num}", I18n.t("validations.household.ecstat.student_16_19.cannot_be_student.child_not_16_19") + record.errors.add "relat#{person_num}", I18n.t("validations.household.relat.student_16_19.cannot_be_child.student_not_16_19") end end @@ -106,6 +91,8 @@ module Validations::Sales::HouseholdValidations end def validate_child_12_years_younger(record) + return unless record.saledate && !record.form.start_year_after_2024? + (2..6).each do |person_num| buyer_1_age = record.public_send("age1") person_age = record.public_send("age#{person_num}") @@ -114,15 +101,9 @@ module Validations::Sales::HouseholdValidations next unless person_age > buyer_1_age - 12 && person_is_child?(relationship) - if record.form.start_year_after_2024? - record.errors.add "age1", I18n.t("validations.household.age.age1_child_12_years_younger_2024", person_num:, person: "buyer") - record.errors.add "age#{person_num}", I18n.t("validations.household.age.child_12_years_younger_2024", person_num:, person: "buyer") - record.errors.add "relat#{person_num}", I18n.t("validations.household.relat.child_12_years_younger_2024", person_num:, person: "buyer") - else - record.errors.add "age1", I18n.t("validations.household.age.child_12_years_younger") - record.errors.add "age#{person_num}", I18n.t("validations.household.age.child_12_years_younger") - record.errors.add "relat#{person_num}", I18n.t("validations.household.age.child_12_years_younger") - end + record.errors.add "age1", I18n.t("validations.household.age.child_12_years_younger") + record.errors.add "age#{person_num}", I18n.t("validations.household.age.child_12_years_younger") + record.errors.add "relat#{person_num}", I18n.t("validations.household.age.child_12_years_younger") end end diff --git a/config/locales/en.yml b/config/locales/en.yml index 0344e1673..5fe718faa 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -463,17 +463,13 @@ en: child_over_16: "Answer cannot be over 16 as person’s %{person_num} working situation is ‘child under 16‘" child_over_20: "Answer cannot be 20 or over as the relationship is ‘child’" child_12_years_younger: "A child must be at least 12 years younger than their parent" - child_12_years_younger_2024: "Age must be at least 12 years younger than the %{person} as person %{person_num}'s relationship to %{person} is child." - age1_child_12_years_younger_2024: "Age must be at least 12 years older than person %{person_num}'s age as person %{person_num}'s relationship to %{person} is child." not_student_16_19: "Answer cannot be between 16 and 19 as person %{person_num} is a child of the lead tenant but is not a full-time student" student_16_19: cannot_be_16_19: child_not_student: "Person cannot be aged 16-19 if they have relationship ‘child’ but are not a student" must_be_16_19: "Person must be aged 16-19 if they are a student and have relationship ‘child’" - must_be_16_19_2024: "Person %{person_num}'s age must be 16-19 as their working situation is student and their relationship to the %{person} is child" lead: over_25: "The lead tenant must be under 26 as you told us their housing situation immediately before this letting was a children’s home or foster care" - child_over_19_relat: "Age must be 19 or under as you told us person 2's relationship to the %{person} is child" student_not_child: cannot_be_16_19: "Person cannot be aged 16-19 if they are a student but not a child" ecstat: @@ -485,7 +481,6 @@ en: cannot_be_student: child_not_16_19: "Person cannot be a student if they are not aged 16-19 but have relationship ‘child’" must_be_student: "Person must be a student if they are aged 16-19 and have relationship ‘child’" - must_be_student_2024: "Person %{person_num}'s working situation must be student or prefers not to say, as their age is 16-19 and their relationship to the %{person} is child" retired_male: "Answer cannot be ‘retired’ as the male tenant is under 65" retired_female: "Answer cannot be ‘retired’ as the female tenant is under 60" not_child_16_19: @@ -500,9 +495,7 @@ en: cannot_be_child: student_not_16_19: "Answer cannot be ‘child’ if the person is a student but not aged 16-19" 16_19_not_student: "Answer cannot be ‘child’ if the person is aged 16-19 but not a student" - must_be_child_2024: "Person %{person_num}'s relationship to the %{person} must be child as their working situation is student and their age is 16-19" child_over_19: "Answer cannot be child as you told us person %{person_num} is over 19" - child_12_years_younger_2024: "Relationship cannot be child, as person %{person_num} is less than 12 years younger than the %{person}" buyer_is_a_child: "Relationship cannot be child, as this person is a buyer" housingneeds_a: one_or_two_choices: "You can only select one option or ‘other disabled access needs’ plus ‘wheelchair-accessible housing’, ‘wheelchair access to essential rooms’ or ‘level access housing’" diff --git a/spec/models/validations/household_validations_spec.rb b/spec/models/validations/household_validations_spec.rb index 3c0529f33..d351dc356 100644 --- a/spec/models/validations/household_validations_spec.rb +++ b/spec/models/validations/household_validations_spec.rb @@ -366,20 +366,16 @@ RSpec.describe Validations::HouseholdValidations do record.age2 = 14 record.relat2 = "P" household_validator.validate_person_age_matches_relationship(record) - expect(record.errors["relat2"]) - .to include("Answer cannot be ‘partner’ as you told us person 2's age is under 16") - expect(record.errors["age2"]) - .not_to include("Age cannot be under 16 as you told us person 2's relationship to the lead tenant is partner.") + expect(record.errors["relat2"]).to be_empty + expect(record.errors["age2"]).to be_empty end it "validates person over 19 is not child" do record.age2 = 20 record.relat2 = "C" household_validator.validate_person_age_matches_relationship(record) - expect(record.errors["age2"]) - .to include("Age must be 19 or under as you told us person 2's relationship to the lead tenant is child") - expect(record.errors["relat2"]) - .not_to include("Answer cannot be child, as you told us person 2 is over 19") + expect(record.errors["age2"]).to be_empty + expect(record.errors["relat2"]).to be_empty end end end @@ -535,15 +531,6 @@ RSpec.describe Validations::HouseholdValidations do expect(record.errors["ecstat2"]) .to include(match I18n.t("validations.household.ecstat.student_16_19.cannot_be_student.child_not_16_19")) end - - it "does not set 2024 errors" do - record.age2 = 17 - record.relat2 = "C" - record.ecstat2 = 1 - household_validator.validate_person_age_and_relationship_matches_economic_status(record) - expect(record.errors["ecstat2"]) - .not_to include("Person 2's working situation must be student or prefers not to say, as their age is 16-19 and their relationship to the lead tenant is child") - end end context "with 2024 logs" do @@ -560,37 +547,17 @@ RSpec.describe Validations::HouseholdValidations do end context "when the household contains a tenant’s child between the ages of 16 and 19" do - it "validates that person's economic status must be full time student or refused" do + it "does not add an error" do record.age2 = 17 record.relat2 = "C" record.ecstat2 = 1 household_validator.validate_person_age_and_relationship_matches_economic_status(record) expect(record.errors["ecstat2"]) - .to include("Person 2's working situation must be student or prefers not to say, as their age is 16-19 and their relationship to the lead tenant is child") + .to be_empty expect(record.errors["age2"]) - .to include("Person cannot be aged 16-19 if they have relationship ‘child’ but are not a student") + .to be_empty expect(record.errors["relat2"]) - .to include("Answer cannot be ‘child’ if the person is aged 16-19 but not a student") - end - - it "expects that person can be a full time student" do - record.age2 = 17 - record.relat2 = "C" - record.ecstat2 = 7 - household_validator.validate_person_age_and_relationship_matches_economic_status(record) - expect(record.errors["ecstat2"]).to be_empty - expect(record.errors["age2"]).to be_empty - expect(record.errors["relat2"]).to be_empty - end - - it "expects that person can refuse to share their work status" do - record.age2 = 17 - record.relat2 = "C" - record.ecstat2 = 10 - household_validator.validate_person_age_and_relationship_matches_economic_status(record) - expect(record.errors["ecstat2"]).to be_empty - expect(record.errors["age2"]).to be_empty - expect(record.errors["relat2"]).to be_empty + .to be_empty end end @@ -604,91 +571,24 @@ RSpec.describe Validations::HouseholdValidations do expect(record.errors["age2"]).to be_empty end - it "adds errors for a person who is a child of the lead tenant and a student but not aged 16-19" do + it "does not add errors for a person who is a child of the lead tenant and a student but not aged 16-19" do record.age2 = 14 record.ecstat2 = "7" record.relat2 = "C" household_validator.validate_person_age_and_relationship_matches_economic_status(record) - expect(record.errors["relat2"]) - .to include("Answer cannot be ‘child’ if the person is a student but not aged 16-19") - expect(record.errors["age2"]) - .to include("Person 2's age must be 16-19 as their working situation is student and their relationship to the lead tenant is child") - expect(record.errors["ecstat2"]) - .to include("Person cannot be a student if they are not aged 16-19 but have relationship ‘child’") + expect(record.errors["relat2"]).to be_empty + expect(record.errors["ecstat2"]).to be_empty + expect(record.errors["age2"]).to be_empty end - it "adds errors for a person who is a student and aged 16-19 but not child" do + it "does not add for a person who is a student and aged 16-19 but not child" do record.age2 = 17 record.ecstat2 = "7" record.relat2 = "X" household_validator.validate_person_age_and_relationship_matches_economic_status(record) - expect(record.errors["relat2"]) - .to include("Person 2's relationship to the lead tenant must be child as their working situation is student and their age is 16-19") - expect(record.errors["age2"]) - .to include("Person cannot be aged 16-19 if they are a student but not a child") - expect(record.errors["ecstat2"]) - .to include("Person cannot be a student if they are aged 16-19 but are not a child") - end - end - end - - describe "#validate_child_12_years_younger" do - context "with 2023 logs" do - let(:log_date) { Time.zone.local(2023, 4, 1) } - - before do - Timecop.freeze(log_date) - Singleton.__init__(FormHandler) - end - - after do - Timecop.return - Singleton.__init__(FormHandler) - end - - it "does not run the validation" do - record.age1 = 20 - record.age2 = 17 - record.relat2 = "C" - household_validator.validate_child_12_years_younger(record) - expect(record.errors["age2"]).to be_empty expect(record.errors["relat2"]).to be_empty - end - end - - context "with 2024 logs" do - let(:log_date) { Time.zone.local(2024, 4, 1) } - - before do - Timecop.freeze(log_date) - Singleton.__init__(FormHandler) - end - - after do - Timecop.return - Singleton.__init__(FormHandler) - end - - it "validates that child is at least 12 year younger than lead tenant" do - record.age1 = 20 - record.age2 = 17 - record.relat2 = "C" - household_validator.validate_child_12_years_younger(record) - expect(record.errors["age1"]) - .to include("Age must be at least 12 years older than person 2's age as person 2's relationship to lead tenant is child.") - expect(record.errors["age2"]) - .to include("Age must be at least 12 years younger than the lead tenant as person 2's relationship to lead tenant is child.") - expect(record.errors["relat2"]) - .to include("Relationship cannot be child, as person 2 is less than 12 years younger than the lead tenant") - end - - it "expects that child is at least 12 years younger than lead tenant" do - record.age1 = 30 - record.age2 = 17 - record.relat2 = "C" - household_validator.validate_child_12_years_younger(record) + expect(record.errors["ecstat2"]).to be_empty expect(record.errors["age2"]).to be_empty - expect(record.errors["relat2"]).to be_empty end end end diff --git a/spec/models/validations/sales/household_validations_spec.rb b/spec/models/validations/sales/household_validations_spec.rb index 04cea4440..00eb16832 100644 --- a/spec/models/validations/sales/household_validations_spec.rb +++ b/spec/models/validations/sales/household_validations_spec.rb @@ -79,20 +79,16 @@ RSpec.describe Validations::Sales::HouseholdValidations do record.age2 = 14 record.relat2 = "P" household_validator.validate_person_age_matches_relationship(record) - expect(record.errors["relat2"]) - .to include("Answer cannot be ‘partner’ as you told us person 2's age is under 16") - expect(record.errors["age2"]) - .not_to include("Age cannot be under 16 as you told us person 2's relationship to the buyer is partner.") + expect(record.errors["relat2"]).to be_empty + expect(record.errors["age2"]).to be_empty end it "validates person over 19 is not child" do record.age2 = 20 record.relat2 = "C" household_validator.validate_person_age_matches_relationship(record) - expect(record.errors["age2"]) - .to include("Age must be 19 or under as you told us person 2's relationship to the buyer is child") - expect(record.errors["relat2"]) - .not_to include("Answer cannot be child, as you told us person 2 is over 19") + expect(record.errors["age2"]).to be_empty + expect(record.errors["relat2"]).to be_empty end end end @@ -201,12 +197,9 @@ RSpec.describe Validations::Sales::HouseholdValidations do record.age2 = 17 record.relat2 = "C" household_validator.validate_child_12_years_younger(record) - expect(record.errors["age1"]) - .to include("Age must be at least 12 years older than person 2's age as person 2's relationship to buyer is child.") - expect(record.errors["age2"]) - .to include("Age must be at least 12 years younger than the buyer as person 2's relationship to buyer is child.") - expect(record.errors["relat2"]) - .to include("Relationship cannot be child, as person 2 is less than 12 years younger than the buyer") + expect(record.errors["age1"]).to be_empty + expect(record.errors["age2"]).to be_empty + expect(record.errors["relat2"]).to be_empty end it "expects that child is at least 12 years younger than buyer" do @@ -285,37 +278,17 @@ RSpec.describe Validations::Sales::HouseholdValidations do let(:log_date) { Time.zone.local(2024, 4, 1) } context "when the household contains a tenant’s child between the ages of 16 and 19" do - it "validates that person's economic status must be full time student or refused" do + it "does not add an error" do record.age2 = 17 record.relat2 = "C" record.ecstat2 = 1 household_validator.validate_person_age_and_relationship_matches_economic_status(record) expect(record.errors["ecstat2"]) - .to include("Person 2's working situation must be student or prefers not to say, as their age is 16-19 and their relationship to the buyer is child") + .to be_empty expect(record.errors["age2"]) - .to include("Person cannot be aged 16-19 if they have relationship ‘child’ but are not a student") + .to be_empty expect(record.errors["relat2"]) - .to include("Answer cannot be ‘child’ if the person is aged 16-19 but not a student") - end - - it "expects that person can be a full time student" do - record.age2 = 17 - record.relat2 = "C" - record.ecstat2 = 7 - household_validator.validate_person_age_and_relationship_matches_economic_status(record) - expect(record.errors["ecstat2"]).to be_empty - expect(record.errors["age2"]).to be_empty - expect(record.errors["relat2"]).to be_empty - end - - it "expects that person can refuse to share their work status" do - record.age2 = 17 - record.relat2 = "C" - record.ecstat2 = 10 - household_validator.validate_person_age_and_relationship_matches_economic_status(record) - expect(record.errors["ecstat2"]).to be_empty - expect(record.errors["age2"]).to be_empty - expect(record.errors["relat2"]).to be_empty + .to be_empty end end @@ -329,30 +302,24 @@ RSpec.describe Validations::Sales::HouseholdValidations do expect(record.errors["age2"]).to be_empty end - it "adds errors for a person who is a child of the buyer and a student but not aged 16-19" do + it "does not add errors" do record.age2 = 14 record.ecstat2 = "7" record.relat2 = "C" household_validator.validate_person_age_and_relationship_matches_economic_status(record) - expect(record.errors["relat2"]) - .to include("Answer cannot be ‘child’ if the person is a student but not aged 16-19") - expect(record.errors["age2"]) - .to include("Person 2's age must be 16-19 as their working situation is student and their relationship to the buyer is child") - expect(record.errors["ecstat2"]) - .to include("Person cannot be a student if they are not aged 16-19 but have relationship ‘child’") + expect(record.errors["relat2"]).to be_empty + expect(record.errors["ecstat2"]).to be_empty + expect(record.errors["age2"]).to be_empty end - it "adds errors for a person who is a student and aged 16-19 but not child" do + it "does not add errors for a person who is a student and aged 16-19 but not child" do record.age2 = 17 record.ecstat2 = "7" record.relat2 = "X" household_validator.validate_person_age_and_relationship_matches_economic_status(record) - expect(record.errors["relat2"]) - .to include("Person 2's relationship to the buyer must be child as their working situation is student and their age is 16-19") - expect(record.errors["age2"]) - .to include("Person cannot be aged 16-19 if they are a student but not a child") - expect(record.errors["ecstat2"]) - .to include("Person cannot be a student if they are aged 16-19 but are not a child") + expect(record.errors["relat2"]).to be_empty + expect(record.errors["ecstat2"]).to be_empty + expect(record.errors["age2"]).to be_empty end end end