From 7e306693a8004fbb441521205fa13ebe9b8dcf69 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Bellet Date: Wed, 19 Apr 2023 10:06:44 +0200 Subject: [PATCH] Use Rails standard naming: same name for the route and the method --- app/controllers/spree/admin/orders_controller.rb | 6 +++--- app/models/spree/ability.rb | 2 +- .../{set_distribution.html.haml => distribution.html.haml} | 0 config/routes/spree.rb | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) rename app/views/spree/admin/orders/{set_distribution.html.haml => distribution.html.haml} (100%) diff --git a/app/controllers/spree/admin/orders_controller.rb b/app/controllers/spree/admin/orders_controller.rb index c62a5b017a..bd4b9185f7 100644 --- a/app/controllers/spree/admin/orders_controller.rb +++ b/app/controllers/spree/admin/orders_controller.rb @@ -9,8 +9,8 @@ module Spree helper CheckoutHelper before_action :load_order, only: [:edit, :update, :fire, :resend, - :invoice, :print, :set_distribution] - before_action :load_distribution_choices, only: [:new, :edit, :update, :set_distribution] + :invoice, :print, :distribution] + before_action :load_distribution_choices, only: [:new, :edit, :update, :distribution] before_action :require_distributor_abn, only: :invoice @@ -24,7 +24,7 @@ module Spree redirect_to spree.distribution_admin_order_path(@order) end - def set_distribution + def distribution return if order_params.blank? on_update diff --git a/app/models/spree/ability.rb b/app/models/spree/ability.rb index 4ac5f8b399..f0ae8fda0c 100644 --- a/app/models/spree/ability.rb +++ b/app/models/spree/ability.rb @@ -274,7 +274,7 @@ module Spree # Enterprise User can access orders that are placed inside a OC they coordinate order.order_cycle&.coordinated_by?(user) end - can [:admin, :bulk_management, :managed, :set_distribution], Spree::Order do + can [:admin, :bulk_management, :managed, :distribution], Spree::Order do user.admin? || user.enterprises.any?(&:is_distributor) end can [:admin, :create, :show, :poll], :invoice diff --git a/app/views/spree/admin/orders/set_distribution.html.haml b/app/views/spree/admin/orders/distribution.html.haml similarity index 100% rename from app/views/spree/admin/orders/set_distribution.html.haml rename to app/views/spree/admin/orders/distribution.html.haml diff --git a/config/routes/spree.rb b/config/routes/spree.rb index 18ba8f3698..6959454e22 100644 --- a/config/routes/spree.rb +++ b/config/routes/spree.rb @@ -89,8 +89,8 @@ Spree::Core::Engine.routes.draw do post :resend get :invoice get :print - get :distribution, to: 'orders#set_distribution' - put :distribution, to: 'orders#set_distribution' + get :distribution + put :distribution end collection do