Locking line_items on API update

This commit is contained in:
Rob Harrington
2015-10-09 12:50:34 +11:00
parent ab7bfd10c5
commit 50b3635e7e

View File

@@ -1,9 +1,17 @@
Spree::Api::LineItemsController.class_eval do
after_filter :apply_enterprise_fees, only: :update
around_filter :lock, only: :update
private
def lock
authorize! :read, order
@line_item = order.line_items.find(params[:id])
@line_item.with_lock do
yield
end
end
def apply_enterprise_fees
authorize! :read, order
order.update_distribution_charge!