From 6d2021c8c5f7caec72899a1219811f4666f59f32 Mon Sep 17 00:00:00 2001 From: Richard Lynch Date: Mon, 11 Nov 2024 13:56:25 +0000 Subject: [PATCH] Handle task save failure When the matching_details task fails to save we need to make sure we're setting the `@matching_details` ivar otherwise the view errors. --- app/controllers/admin/tasks_controller.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/controllers/admin/tasks_controller.rb b/app/controllers/admin/tasks_controller.rb index f2881fd1e6..39f4735d4a 100644 --- a/app/controllers/admin/tasks_controller.rb +++ b/app/controllers/admin/tasks_controller.rb @@ -2,7 +2,7 @@ class Admin::TasksController < Admin::BaseAdminController before_action :ensure_service_operator before_action :load_claim before_action :ensure_task_has_not_already_been_completed, only: [:create] - before_action :load_matching_claims, only: [:show], if: -> { params[:name] == "matching_details" } + before_action :load_matching_claims, only: [:show], if: :load_matching_claims? def index @claim_checking_tasks = ClaimCheckingTasks.new(@claim) @@ -29,6 +29,7 @@ def create if @task.save redirect_to @task_pagination.next_task_path else + load_matching_claims if load_matching_claims? @tasks_presenter = @claim.policy::AdminTasksPresenter.new(@claim) render @task.name end @@ -75,6 +76,10 @@ def load_matching_claims @matching_claims = Claim::MatchingAttributeFinder.new(@claim).matching_claims end + def load_matching_claims? + params[:name] == "matching_details" + end + def current_task_name @task.name end