From 20142ca632955e56502da669f5ce2616f80f8e3f Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Bellet Date: Wed, 30 Mar 2022 09:41:57 +0200 Subject: [PATCH] Add a spec on canceling an order, and check email is sent Co-Authored-By: Maikel --- spec/system/admin/order_spec.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/spec/system/admin/order_spec.rb b/spec/system/admin/order_spec.rb index 7e726839d1..71eb64acd4 100644 --- a/spec/system/admin/order_spec.rb +++ b/spec/system/admin/order_spec.rb @@ -208,6 +208,22 @@ describe ' end end + context "user can cancel an order" do + before do + login_as_admin_and_visit spree.edit_admin_order_path(order) + end + + it "by clicking on the cancel button" do + expect do + accept_alert do + click_button "Cancel" + end + expect(page).to have_content "Order updated" + expect(order.reload.state).to eq("canceled") + end.to have_enqueued_mail(Spree::OrderMailer, :cancel_email) + end + end + it "can't add more items than are available" do # Move the order back to the cart state order.state = 'cart'