Browse Source

Fix optionality

pull/563/head
baarkerlounger 3 years ago
parent
commit
cea676acdc
  1. 6
      app/models/case_log.rb
  2. 26
      spec/models/case_log_spec.rb

6
app/models/case_log.rb

@ -186,8 +186,8 @@ class CaseLog < ApplicationRecord
previous_la_known == 1
end
def tshortfall_known?
!!(tshortfall_known && tshortfall_known.zero?)
def tshortfall_unknown?
tshortfall_known == 1
end
def is_secure_tenancy?
@ -433,7 +433,7 @@ private
def dynamically_not_required
previous_la_known_field = postcode_known? ? %w[previous_la_known] : []
tshortfall_field = tshortfall_known? ? [] : %w[tshortfall]
tshortfall_field = tshortfall_unknown? ? %w[tshortfall] : []
previous_la_known_field + tshortfall_field
end

26
spec/models/case_log_spec.rb

@ -1771,6 +1771,32 @@ RSpec.describe CaseLog do
end
end
describe "tshortfall_unknown?" do
context "when tshortfall is nil" do
let(:case_log) { FactoryBot.create(:case_log, :in_progress, tshortfall_known: nil) }
it "returns false" do
expect(case_log.tshortfall_unknown?).to be false
end
end
context "when tshortfall is No" do
let(:case_log) { FactoryBot.create(:case_log, :in_progress, tshortfall_known: 1) }
it "returns false" do
expect(case_log.tshortfall_unknown?).to be true
end
end
context "when tshortfall is Yes" do
let(:case_log) { FactoryBot.create(:case_log, :in_progress, tshortfall_known: 0) }
it "returns false" do
expect(case_log.tshortfall_unknown?).to be false
end
end
end
describe "paper trail" do
let(:case_log) { FactoryBot.create(:case_log, :in_progress) }

Loading…
Cancel
Save