From fdc77debb2a8ef08b463cace3c2926f94b50d52b Mon Sep 17 00:00:00 2001 From: Alkesh Vaghmaria Date: Thu, 24 Oct 2024 15:46:37 +0100 Subject: [PATCH] cope with claims with no submitted_at in admin view --- app/models/claim.rb | 2 +- app/views/admin/claims/index.html.erb | 2 +- spec/models/claim_spec.rb | 17 +++++++++++++++++ 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/app/models/claim.rb b/app/models/claim.rb index fd1af663a4..84cb1104f5 100644 --- a/app/models/claim.rb +++ b/app/models/claim.rb @@ -318,7 +318,7 @@ def payment_prevented_by_other_claims? end def decision_deadline_date - (submitted_at + DECISION_DEADLINE).to_date + (submitted_at + DECISION_DEADLINE).to_date if submitted? end def address(separator = ", ") diff --git a/app/views/admin/claims/index.html.erb b/app/views/admin/claims/index.html.erb index ceb39ecd52..3d6cf32b9e 100644 --- a/app/views/admin/claims/index.html.erb +++ b/app/views/admin/claims/index.html.erb @@ -85,7 +85,7 @@ <% if claims_with_warning.nonzero? %> <%= decision_deadline_warning(claim) %> <% end %> - <%= l(claim.decision_deadline_date) %> + <%= l(claim.decision_deadline_date) if claim.submitted? %> <%= claim.assigned_to.present? ? claim.assigned_to.full_name.titleize : nil %> <% end %> diff --git a/spec/models/claim_spec.rb b/spec/models/claim_spec.rb index dbc071a3bb..331b58ad28 100644 --- a/spec/models/claim_spec.rb +++ b/spec/models/claim_spec.rb @@ -1397,4 +1397,21 @@ it { is_expected.to be false } end end + + describe "#decision_deadline_date" do + subject { claim.decision_deadline_date } + + before { travel_to Date.new(2024, 1, 1) } + + context "when submitted_at populated" do + let(:claim) { create(:claim, :early_years_provider_submitted, policy: Policies::EarlyYearsPayments) } + it { is_expected.to eq nil } + end + + context "when submitted_at not populated" do + let(:claim) { create(:claim, :submitted, policy: Policies::EarlyYearsPayments) } + + it { is_expected.to eq Date.new(2024, 3, 25) } + end + end end