Browse Source

Refactor

pull/2396/head
Kat 2 years ago
parent
commit
264b202472
  1. 2
      app/models/form/sales/questions/mortgage_amount.rb
  2. 8
      spec/models/form/sales/questions/mortgage_amount_spec.rb

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

@ -20,6 +20,6 @@ class Form::Sales::Questions::MortgageAmount < ::Form::Question
}.freeze }.freeze
def derived?(log) def derived?(log)
log && log.mortgage_not_used? log&.mortgage_not_used?
end end
end end

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

@ -48,18 +48,18 @@ RSpec.describe Form::Sales::Questions::MortgageAmount, type: :model do
end end
context "when the mortgage is not used" do context "when the mortgage is not used" do
let(:log) { create(:sales_log, :completed, mortgageused: 2, deposit: nil) } let(:log) { build(:sales_log, :completed, mortgageused: 2, deposit: nil) }
it "is marked as derived" do it "is marked as derived" do
expect(question.derived?(log)).to be true expect(question).to be_derived(log)
end end
end end
context "when the mortgage is used" do context "when the mortgage is used" do
let(:log) { create(:sales_log, :completed, mortgageused: 1) } let(:log) { build(:sales_log, :completed, mortgageused: 1) }
it "is marked as derived" do it "is marked as derived" do
expect(question.derived?(log)).to be false expect(question).not_to be_derived(log)
end end
end end
end end

Loading…
Cancel
Save