diff --git a/app/controllers/spree/api/line_items_controller_decorator.rb b/app/controllers/spree/api/line_items_controller_decorator.rb index 1f6498cc86..93e4099d2a 100644 --- a/app/controllers/spree/api/line_items_controller_decorator.rb +++ b/app/controllers/spree/api/line_items_controller_decorator.rb @@ -1,19 +1,13 @@ Spree::Api::LineItemsController.class_eval do - after_filter :apply_enterprise_fees, only: :update - around_filter :lock, only: :update + around_filter :apply_enterprise_fees_with_lock, only: :update private - def lock + def apply_enterprise_fees_with_lock authorize! :read, order - @line_item = order.line_items.find(params[:id]) - @line_item.with_lock do + order.with_lock do yield + order.update_distribution_charge! end end - - def apply_enterprise_fees - authorize! :read, order - order.update_distribution_charge! - end end