From c0ecc6af5d5f420971e133ba70663cca5f90243d Mon Sep 17 00:00:00 2001 From: Klaus Zanders Date: Tue, 9 Jun 2026 11:50:28 +0200 Subject: [PATCH] Fix rubocop issue in Controller --- .../resource_allocations_controller.rb | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/modules/resource_management/app/controllers/resource_management/resource_allocations_controller.rb b/modules/resource_management/app/controllers/resource_management/resource_allocations_controller.rb index b8126bfe3aa..10c00db44c1 100644 --- a/modules/resource_management/app/controllers/resource_management/resource_allocations_controller.rb +++ b/modules/resource_management/app/controllers/resource_management/resource_allocations_controller.rb @@ -53,17 +53,11 @@ module ::ResourceManagement def create # The confirmation step's "Back" button resubmits the carried form values # so the editable step can be re-rendered pre-filled. - return render_allocation_step(set_attributes(create_params).result) if params[:back].present? + return render_back_step if params[:back].present? validation = set_attributes(create_params) - - if validation.failure? - return render_allocation_step(validation.result, status: :unprocessable_entity) - end - - if validation.result.schedule_violation && params[:confirmed].blank? - return render_outside_dates_step(validation.result) - end + return render_allocation_step(validation.result, status: :unprocessable_entity) if validation.failure? + return render_outside_dates_step(validation.result) if needs_date_confirmation?(validation.result) persist_allocation end @@ -113,6 +107,14 @@ module ::ResourceManagement end end + def render_back_step + render_allocation_step(set_attributes(create_params).result) + end + + def needs_date_confirmation?(allocation) + allocation.schedule_violation && params[:confirmed].blank? + end + def set_attributes(attributes) ResourceAllocations::SetAttributesService .new(user: current_user, model: ResourceAllocation.new, contract_class: ResourceAllocations::CreateContract)