diff --git a/app/models/validations/sales/household_validations.rb b/app/models/validations/sales/household_validations.rb index 3db3fb85f..8c4673c07 100644 --- a/app/models/validations/sales/household_validations.rb +++ b/app/models/validations/sales/household_validations.rb @@ -107,14 +107,6 @@ module Validations::Sales::HouseholdValidations end end - def validate_buyer_2_not_child(record) - return unless record.form.start_year_after_2024? - - if record.joint_purchase? && person_is_child?(record.relat2) - record.errors.add "relat2", I18n.t("validations.household.relat.buyer_is_a_child") - end - end - private def person_is_fulltime_student?(economic_status) diff --git a/config/locales/en.yml b/config/locales/en.yml index 5fe718faa..60d95345d 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -496,7 +496,6 @@ en: 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" child_over_19: "Answer cannot be child as you told us person %{person_num} is over 19" - 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’" housingneeds_type: diff --git a/spec/models/validations/household_validations_spec.rb b/spec/models/validations/household_validations_spec.rb index d351dc356..c31cee46d 100644 --- a/spec/models/validations/household_validations_spec.rb +++ b/spec/models/validations/household_validations_spec.rb @@ -362,7 +362,7 @@ RSpec.describe Validations::HouseholdValidations do Singleton.__init__(FormHandler) end - it "validates person under 16 is not partner" do + it "does not add an error is person under 16 is a partner" do record.age2 = 14 record.relat2 = "P" household_validator.validate_person_age_matches_relationship(record) @@ -370,7 +370,7 @@ RSpec.describe Validations::HouseholdValidations do expect(record.errors["age2"]).to be_empty end - it "validates person over 19 is not child" do + it "does not add an error if person over 19 is child" do record.age2 = 20 record.relat2 = "C" household_validator.validate_person_age_matches_relationship(record) diff --git a/spec/models/validations/sales/household_validations_spec.rb b/spec/models/validations/sales/household_validations_spec.rb index 00eb16832..8cefccdb1 100644 --- a/spec/models/validations/sales/household_validations_spec.rb +++ b/spec/models/validations/sales/household_validations_spec.rb @@ -75,7 +75,7 @@ RSpec.describe Validations::Sales::HouseholdValidations do context "with 2024 logs" do let(:log_date) { Time.zone.local(2024, 4, 1) } - it "validates person under 16 is not partner" do + it "does not add error if person under 16 is a partner" do record.age2 = 14 record.relat2 = "P" household_validator.validate_person_age_matches_relationship(record) @@ -83,7 +83,7 @@ RSpec.describe Validations::Sales::HouseholdValidations do expect(record.errors["age2"]).to be_empty end - it "validates person over 19 is not child" do + it "does not add error if person over 19 is a child" do record.age2 = 20 record.relat2 = "C" household_validator.validate_person_age_matches_relationship(record) @@ -192,7 +192,7 @@ RSpec.describe Validations::Sales::HouseholdValidations do context "with 2024 logs" do let(:log_date) { Time.zone.local(2024, 4, 1) } - it "validates that child is at least 12 year younger than buyer" do + it "does not validate that child is at least 12 year younger than buyer" do record.age1 = 20 record.age2 = 17 record.relat2 = "C" @@ -201,15 +201,6 @@ RSpec.describe Validations::Sales::HouseholdValidations do 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 - record.age1 = 30 - 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 end @@ -324,41 +315,6 @@ RSpec.describe Validations::Sales::HouseholdValidations do end end - describe "#validate_buyer_2_not_child" do - before do - Timecop.freeze(log_date) - Singleton.__init__(FormHandler) - end - - after do - Timecop.return - Singleton.__init__(FormHandler) - end - - context "with 2023 logs" do - let(:log_date) { Time.zone.local(2023, 4, 1) } - - it "does not add an error if buyer 2 is a child" do - record.jointpur = 1 - record.relat2 = "C" - household_validator.validate_buyer_2_not_child(record) - expect(record.errors["relat2"]).to be_empty - end - end - - context "with 2024 logs" do - let(:log_date) { Time.zone.local(2024, 4, 1) } - - it "validates buyer 2 isn't a child" do - record.jointpur = 1 - record.relat2 = "C" - household_validator.validate_buyer_2_not_child(record) - expect(record.errors["relat2"]) - .to include("Relationship cannot be child, as this person is a buyer") - end - end - end - describe "validating fields about buyers living in the property" do let(:sales_log) { FactoryBot.create(:sales_log, :outright_sale_setup_complete, noint: 1, companybuy: 2, buylivein:, jointpur:, jointmore:, buy1livein:) }