Extract order-updating logic to Order::Updater

This commit is contained in:
Matt-Yorkley
2021-04-26 08:55:14 +01:00
parent 8e10f7af0e
commit 00c4a28d22
3 changed files with 27 additions and 15 deletions

View File

@@ -556,11 +556,19 @@ describe Spree::Payment do
end
context "completed orders" do
let(:order_updater) { OrderManagement::Order::Updater.new(order) }
before { allow(order).to receive(:completed?) { true } }
it "updates payment_state and shipments" do
expect(order.updater).to receive(:update_payment_state)
expect(order.updater).to receive(:update_shipment_state)
expect(OrderManagement::Order::Updater).to receive(:new).with(order).
and_return(order_updater)
expect(order_updater).to receive(:after_payment_update).with(kind_of(Spree::Payment)).
and_call_original
expect(order_updater).to receive(:update_payment_state)
expect(order_updater).to receive(:update_shipment_state)
create(:payment, amount: 100, order: order)
end
end