Browse Source

CLDC-3412 set derived? on mortgage amount (#2396)

* Set derived on mortgage amount

* Refactor
pull/2411/head
kosiakkatrina 8 months ago committed by GitHub
parent
commit
30bb983e78
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 4
      app/models/form/sales/questions/mortgage_amount.rb
  2. 18
      spec/models/form/sales/questions/mortgage_amount_spec.rb

4
app/models/form/sales/questions/mortgage_amount.rb

@ -18,4 +18,8 @@ class Form::Sales::Questions::MortgageAmount < ::Form::Question
2023 => { 1 => 91, 2 => 104, 3 => 112 },
2024 => { 1 => 92, 2 => 105, 3 => 113 },
}.freeze
def derived?(log)
log&.mortgage_not_used?
end
end

18
spec/models/form/sales/questions/mortgage_amount_spec.rb

@ -28,7 +28,7 @@ RSpec.describe Form::Sales::Questions::MortgageAmount, type: :model do
end
it "is not marked as derived" do
expect(question.derived?(nil)).to be false
expect(question).not_to be_derived(nil)
end
it "has the correct hint" do
@ -46,4 +46,20 @@ RSpec.describe Form::Sales::Questions::MortgageAmount, type: :model do
it "has correct min" do
expect(question.min).to be(1)
end
context "when the mortgage is not used" do
let(:log) { build(:sales_log, :completed, mortgageused: 2, deposit: nil) }
it "is marked as derived" do
expect(question).to be_derived(log)
end
end
context "when the mortgage is used" do
let(:log) { build(:sales_log, :completed, mortgageused: 1) }
it "is marked as derived" do
expect(question).not_to be_derived(log)
end
end
end

Loading…
Cancel
Save