Browse Source

remove validate_years_living_in_property_before_purchase (#1878)

pull/1884/head
kosiakkatrina 1 year ago committed by GitHub
parent
commit
9ae32ac266
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 13
      app/models/validations/sales/sale_information_validations.rb
  2. 54
      spec/models/validations/sales/sale_information_validations_spec.rb

13
app/models/validations/sales/sale_information_validations.rb

@ -11,19 +11,6 @@ module Validations::Sales::SaleInformationValidations
end end
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) def validate_exchange_date(record)
return unless record.exdate && record.saledate return unless record.exdate && record.saledate

54
spec/models/validations/sales/sale_information_validations_spec.rb

@ -171,60 +171,6 @@ RSpec.describe Validations::Sales::SaleInformationValidations do
end end
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 describe "#validate_discounted_ownership_value" do
context "when sale is on or after 24/25 collection window" do context "when sale is on or after 24/25 collection window" do
context "when grant is routed to" do context "when grant is routed to" do

Loading…
Cancel
Save