From 72c6935ff8ff4fa586cd0185e4b2f54b0975f26e Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Sat, 27 Mar 2021 14:54:27 +0000 Subject: [PATCH] Fix handling of empty order cycle params This guard clause was returning an instance of an unpermitted Params object (containing a blank hash) here, which was causing unexpected results in various places. Returning a blank hash explicitly resolved the issue. Fixes: 4) Admin::OrderCyclesController create as a manager of a shop when creation is successful returns success: true and a valid edit path Failure/Error: @order_cycle_params ||= PermittedAttributes::OrderCycle.new(params).call. to_h.with_indifferent_access ActionController::UnfilteredParameters: unable to convert unpermitted parameters to hash # ./app/controllers/admin/order_cycles_controller.rb:245:in `order_cycle_params' # ./app/controllers/admin/order_cycles_controller.rb:44:in `create' # ./spec/support/controller_requests_helper.rb:49:in `process_action_with_route' # ./spec/support/controller_requests_helper.rb:27:in `spree_post' # ./spec/controllers/admin/order_cycles_controller_spec.rb:124:in `block (5 levels) in ' --- app/services/permitted_attributes/order_cycle.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/services/permitted_attributes/order_cycle.rb b/app/services/permitted_attributes/order_cycle.rb index 046726a96f..f46a4c63d2 100644 --- a/app/services/permitted_attributes/order_cycle.rb +++ b/app/services/permitted_attributes/order_cycle.rb @@ -7,7 +7,7 @@ module PermittedAttributes end def call - return @params[:order_cycle] if @params[:order_cycle].blank? + return {} if @params[:order_cycle].blank? @params.require(:order_cycle).permit(attributes) end