mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Delete unused spree/api/line_items_controller_decorator.rb
This commit is contained in:
@@ -1,13 +0,0 @@
|
||||
Spree::Api::LineItemsController.class_eval do
|
||||
around_filter :apply_enterprise_fees_with_lock, only: :update
|
||||
|
||||
private
|
||||
|
||||
def apply_enterprise_fees_with_lock
|
||||
authorize! :read, order
|
||||
order.with_lock do
|
||||
yield
|
||||
order.update_distribution_charge!
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,35 +0,0 @@
|
||||
require 'spec_helper'
|
||||
|
||||
module Spree
|
||||
describe Spree::Api::LineItemsController, type: :controller do
|
||||
render_views
|
||||
|
||||
before do
|
||||
allow(controller).to receive(:spree_current_user) { current_api_user }
|
||||
end
|
||||
|
||||
# test that when a line item is updated, an order's fees are updated too
|
||||
context "as an admin user" do
|
||||
sign_in_as_admin!
|
||||
|
||||
let(:order) { FactoryBot.create(:order, state: 'complete', completed_at: Time.zone.now) }
|
||||
let(:line_item) { FactoryBot.create(:line_item_with_shipment, order: order, final_weight_volume: 500) }
|
||||
|
||||
context "as a line item is updated" do
|
||||
before { allow(controller).to receive(:order) { order } }
|
||||
|
||||
it "update distribution charge on the order" do
|
||||
line_item_params = {
|
||||
order_id: order.number,
|
||||
id: line_item.id,
|
||||
line_item: { id: line_item.id, final_weight_volume: 520 },
|
||||
format: :json
|
||||
}
|
||||
|
||||
expect(order).to receive(:update_distribution_charge!)
|
||||
spree_post :update, line_item_params
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user