Skip to content

Commit

Permalink
cope with claims with no submitted_at in admin view
Browse files Browse the repository at this point in the history
  • Loading branch information
alkesh committed Oct 24, 2024
1 parent e46a8b2 commit fdc77de
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/models/claim.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ", ")
Expand Down
2 changes: 1 addition & 1 deletion app/views/admin/claims/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
<% if claims_with_warning.nonzero? %>
<td class="govuk-table__cell"><%= decision_deadline_warning(claim) %></td>
<% end %>
<td class="govuk-table__cell"><%= l(claim.decision_deadline_date) %></td>
<td class="govuk-table__cell"><%= l(claim.decision_deadline_date) if claim.submitted? %></td>
<td class="govuk-table__cell"><%= claim.assigned_to.present? ? claim.assigned_to.full_name.titleize : nil %></td>
</tr>
<% end %>
Expand Down
17 changes: 17 additions & 0 deletions spec/models/claim_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit fdc77de

Please sign in to comment.