Wrapping line_item update with order.update_distribution_charge inside lock

This commit is contained in:
Rob Harrington
2015-10-09 16:45:13 +11:00
parent 50b3635e7e
commit f60b6994eb

View File

@@ -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