From f60b6994eb589a18ca469b0bc502d78bc14537f9 Mon Sep 17 00:00:00 2001 From: Rob Harrington Date: Fri, 9 Oct 2015 16:45:13 +1100 Subject: [PATCH] Wrapping line_item update with order.update_distribution_charge inside lock --- .../spree/api/line_items_controller_decorator.rb | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) 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