Browse Source

add savings_over_soft_max? soft validation

pull/1102/head
Kat 3 years ago
parent
commit
7e5b747153
  1. 4
      app/models/validations/sales/soft_validations.rb
  2. 22
      spec/models/validations/sales/soft_validations_spec.rb

4
app/models/validations/sales/soft_validations.rb

@ -26,4 +26,8 @@ module Validations::Sales::SoftValidations
wheel == 1
end
def savings_over_soft_max?
savings && savings > 100_000
end
end

22
spec/models/validations/sales/soft_validations_spec.rb

@ -201,4 +201,26 @@ RSpec.describe Validations::Sales::SoftValidations do
end
end
end
describe "savings amount validations" do
context "when validating soft max" do
it "returns false if no savings is given" do
record.savings = nil
expect(record)
.not_to be_savings_over_soft_max
end
it "savings is over 100_000" do
record.savings = 100_001
expect(record)
.to be_savings_over_soft_max
end
it "savings is under 100_000" do
record.savings = 99_999
expect(record)
.not_to be_mortgage_over_soft_max
end
end
end
end

Loading…
Cancel
Save