Skip to content

Commit

Permalink
Handle task save failure
Browse files Browse the repository at this point in the history
When the matching_details task fails to save we need to make sure we're
setting the `@matching_details` ivar otherwise the view errors.
  • Loading branch information
rjlynch committed Nov 13, 2024
1 parent 26af612 commit 6d2021c
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion app/controllers/admin/tasks_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 6d2021c

Please sign in to comment.