diff --git a/app/models/case_log.rb b/app/models/case_log.rb index 812c85037..5e78990f3 100644 --- a/app/models/case_log.rb +++ b/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 diff --git a/spec/models/case_log_spec.rb b/spec/models/case_log_spec.rb index 1a3e21c03..f420ade1c 100644 --- a/spec/models/case_log_spec.rb +++ b/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) }