From 469019db7e36f2b022c951edf8418396e692524d Mon Sep 17 00:00:00 2001 From: Kat Date: Tue, 6 Feb 2024 16:47:23 +0000 Subject: [PATCH] Fix soft validation --- app/models/validations/sales/soft_validations.rb | 5 ++--- .../validations/sales/soft_validations_spec.rb | 12 ++++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/app/models/validations/sales/soft_validations.rb b/app/models/validations/sales/soft_validations.rb index a2d1de7fd..ae9ee66cc 100644 --- a/app/models/validations/sales/soft_validations.rb +++ b/app/models/validations/sales/soft_validations.rb @@ -116,9 +116,8 @@ module Validations::Sales::SoftValidations end def grant_outside_common_range? - return unless grant - return unless type && saledate - return unless !form.start_year_after_2024? || type == 21 || type == 8 + return unless grant && type && saledate + return if form.start_year_after_2024? && (type == 21 || type == 8) !grant.between?(9_000, 16_000) end diff --git a/spec/models/validations/sales/soft_validations_spec.rb b/spec/models/validations/sales/soft_validations_spec.rb index 170c474b7..e417fbd8e 100644 --- a/spec/models/validations/sales/soft_validations_spec.rb +++ b/spec/models/validations/sales/soft_validations_spec.rb @@ -682,28 +682,28 @@ RSpec.describe Validations::Sales::SoftValidations do expect(record).not_to be_grant_outside_common_range end - it "returns true for logs after 2024 with RTA" do + it "returns false for logs after 2024 with RTA" do record.grant = 100_000 record.type = 8 record.saledate = Time.zone.local(2025, 1, 1) - expect(record).to be_grant_outside_common_range + expect(record).not_to be_grant_outside_common_range end - it "returns true for logs after 2024 with socialBuy" do + it "returns false for logs after 2024 with socialBuy" do record.grant = 100_000 record.type = 21 record.saledate = Time.zone.local(2025, 1, 1) - expect(record).to be_grant_outside_common_range + expect(record).not_to be_grant_outside_common_range end - it "returns false for logs after 2024 with other type" do + it "returns true for logs after 2024 with other type" do record.grant = 100_000 record.type = 9 record.saledate = Time.zone.local(2025, 1, 1) - expect(record).not_to be_grant_outside_common_range + expect(record).to be_grant_outside_common_range end end