From 9ae32ac2664594f5b7e1ea02e2e7d1e5ddba7c50 Mon Sep 17 00:00:00 2001 From: kosiakkatrina <54268893+kosiakkatrina@users.noreply.github.com> Date: Fri, 1 Sep 2023 17:23:14 +0200 Subject: [PATCH] remove validate_years_living_in_property_before_purchase (#1878) --- .../sales/sale_information_validations.rb | 13 ----- .../sale_information_validations_spec.rb | 54 ------------------- 2 files changed, 67 deletions(-) diff --git a/app/models/validations/sales/sale_information_validations.rb b/app/models/validations/sales/sale_information_validations.rb index b802fa08f..3f4d06a30 100644 --- a/app/models/validations/sales/sale_information_validations.rb +++ b/app/models/validations/sales/sale_information_validations.rb @@ -11,19 +11,6 @@ module Validations::Sales::SaleInformationValidations end end - def validate_years_living_in_property_before_purchase(record) - return unless record.proplen&.nonzero? - - case record.type - when 18 - record.errors.add :type, I18n.t("validations.sale_information.proplen.social_homebuy") - record.errors.add :proplen, I18n.t("validations.sale_information.proplen.social_homebuy") - when 28, 29 - record.errors.add :type, I18n.t("validations.sale_information.proplen.rent_to_buy") - record.errors.add :proplen, I18n.t("validations.sale_information.proplen.rent_to_buy") - end - end - def validate_exchange_date(record) return unless record.exdate && record.saledate diff --git a/spec/models/validations/sales/sale_information_validations_spec.rb b/spec/models/validations/sales/sale_information_validations_spec.rb index cccb19d40..dbd4c1e49 100644 --- a/spec/models/validations/sales/sale_information_validations_spec.rb +++ b/spec/models/validations/sales/sale_information_validations_spec.rb @@ -171,60 +171,6 @@ RSpec.describe Validations::Sales::SaleInformationValidations do end end - describe "#validate_years_living_in_property_before_purchase" do - context "when proplen blank" do - let(:record) { build(:sales_log, proplen: nil) } - - it "does not add an error" do - sale_information_validator.validate_years_living_in_property_before_purchase(record) - - expect(record.errors).not_to be_present - end - end - - context "when type blank" do - let(:record) { build(:sales_log, type: nil) } - - it "does not add an error" do - sale_information_validator.validate_years_living_in_property_before_purchase(record) - - expect(record.errors).not_to be_present - end - end - - context "when proplen 0" do - let(:record) { build(:sales_log, proplen: 0) } - - it "does not add an error" do - sale_information_validator.validate_years_living_in_property_before_purchase(record) - - expect(record.errors).not_to be_present - end - end - - context "when type Rent to Buy and proplen > 0" do - let(:record) { build(:sales_log, proplen: 1, type: 28) } - - it "adds an error" do - sale_information_validator.validate_years_living_in_property_before_purchase(record) - - expect(record.errors[:type]).to include(I18n.t("validations.sale_information.proplen.rent_to_buy")) - expect(record.errors[:proplen]).to include(I18n.t("validations.sale_information.proplen.rent_to_buy")) - end - end - - context "when type Social HomeBuy and proplen > 0" do - let(:record) { build(:sales_log, proplen: 1, type: 18) } - - it "adds an error" do - sale_information_validator.validate_years_living_in_property_before_purchase(record) - - expect(record.errors[:type]).to include(I18n.t("validations.sale_information.proplen.social_homebuy")) - expect(record.errors[:proplen]).to include(I18n.t("validations.sale_information.proplen.social_homebuy")) - end - end - end - describe "#validate_discounted_ownership_value" do context "when sale is on or after 24/25 collection window" do context "when grant is routed to" do