From 18aa0f4901d230e001ef9104f8723230a235d282 Mon Sep 17 00:00:00 2001 From: natdeanlewissoftwire Date: Wed, 25 Jan 2023 11:05:40 +0000 Subject: [PATCH] test: add validation tests --- .../sales/soft_validations_spec.rb | 63 +++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/spec/models/validations/sales/soft_validations_spec.rb b/spec/models/validations/sales/soft_validations_spec.rb index b7f2c11fb..97df7d921 100644 --- a/spec/models/validations/sales/soft_validations_spec.rb +++ b/spec/models/validations/sales/soft_validations_spec.rb @@ -329,4 +329,67 @@ RSpec.describe Validations::Sales::SoftValidations do expect(record).not_to be_wheelchair_when_not_disabled end end + + describe "purchase_price_out_of_soft_range" do + before do + LaPurchasePriceRange.create!( + la: "E07000223", + bedrooms: 2, + soft_min: 177000, + soft_max: 384000, + start_year: 2022, + ) + end + it "when value not set" do + record.value = nil + + expect(record).not_to be_purchase_price_out_of_soft_range + end + + it "when beds not set" do + record.beds = nil + + expect(record).not_to be_purchase_price_out_of_soft_range + end + + it "when la not set" do + record.la = nil + + expect(record).not_to be_purchase_price_out_of_soft_range + end + + it "when saledate not set" do + record.saledate = nil + + + expect(record).not_to be_purchase_price_out_of_soft_range + end + + it "when below soft min" do + record.value = 176_999 + record.beds = 2 + record.la = "E07000223" + record.saledate = Time.zone.local(2023, 1, 1) + + expect(record).to be_purchase_price_out_of_soft_range + end + + it "when above soft max" do + record.value = 384_001 + record.beds = 2 + record.la = "E07000223" + record.saledate = Time.zone.local(2023, 1, 1) + + expect(record).to be_purchase_price_out_of_soft_range + end + + it "when in soft range" do + record.value = 200_000 + record.beds = 2 + record.la = "E07000223" + record.saledate = Time.zone.local(2023, 1, 1) + + expect(record).not_to be_purchase_price_out_of_soft_range + end + end end