Use service in admin/orders/customer_details#update

This commit is contained in:
Kristina Lim
2019-03-13 14:52:33 +11:00
parent abaf90fc41
commit 0e691815ea
2 changed files with 10 additions and 1 deletions

View File

@@ -6,7 +6,8 @@ Spree::Admin::Orders::CustomerDetailsController.class_eval do
if params[:guest_checkout] == "false"
@order.associate_user!(Spree.user_class.find_by_email(@order.email))
end
while @order.next; end
AdvanceOrderService.new(@order).call
@order.shipments.map &:refresh_rates
flash[:success] = Spree.t('customer_details_updated')

View File

@@ -39,6 +39,14 @@ describe Spree::Admin::Orders::CustomerDetailsController, type: :controller do
login_as_enterprise_user [order.distributor]
end
it "advances the order state" do
expect {
spree_post :update, order: { email: user.email, bill_address_attributes: address_params,
ship_address_attributes: address_params },
order_id: order.number
}.to change { order.reload.state }.from("cart").to("complete")
end
context "when adding details of a registered user" do
it "redirects to shipments on success" do
spree_post :update, order: { email: user.email, bill_address_attributes: address_params, ship_address_attributes: address_params }, order_id: order.number