From c185a47592833f04fce41822b9f0f5d8d6192c63 Mon Sep 17 00:00:00 2001 From: Mohamed ABDELLANI Date: Mon, 7 Aug 2023 17:04:24 +0100 Subject: [PATCH 1/2] render the confirm model on the same component that includes the action on the order. --- .../spree/admin/shared/_order_links.html.haml | 2 + spec/system/admin/order_spec.rb | 48 +++++++++++++------ 2 files changed, 36 insertions(+), 14 deletions(-) diff --git a/app/views/spree/admin/shared/_order_links.html.haml b/app/views/spree/admin/shared/_order_links.html.haml index a05e5a00d1..195b111f27 100644 --- a/app/views/spree/admin/shared/_order_links.html.haml +++ b/app/views/spree/admin/shared/_order_links.html.haml @@ -10,3 +10,5 @@ %span %i{ class: link[:icon] } %span=link[:name] + += render 'spree/admin/shared/custom-confirm' \ No newline at end of file diff --git a/spec/system/admin/order_spec.rb b/spec/system/admin/order_spec.rb index 37b0043c00..4eea8316e2 100644 --- a/spec/system/admin/order_spec.rb +++ b/spec/system/admin/order_spec.rb @@ -608,26 +608,46 @@ describe ' end context "Canceling an order" do - before do - visit spree.edit_admin_order_path(order) - find("#links-dropdown .ofn-drop-down").click + shared_examples "canceling an order" do + it "shows the link" do + expect(page).to have_link "Cancel Order", + href: spree.fire_admin_order_path(order, e: 'cancel') + end + it 'cancels the order' do + within ".ofn-drop-down .menu" do + expect(page).to have_selector("span", text: "Cancel Order") + page.find("span", text: "Cancel Order").click + end + within '.modal-content' do + expect { + find_button("OK").click + }.to change { order.reload.state }.from('complete').to('canceled') + end + end end - it "shows the link" do - expect(page).to have_link "Cancel Order", - href: spree.fire_admin_order_path(order, e: 'cancel') + context "from order details page" do + before do + visit spree.edit_admin_order_path(order) + find("#links-dropdown .ofn-drop-down").click + end + it_behaves_like "canceling an order" end - it "cancels the order" do - within ".ofn-drop-down .menu" do - expect(page).to have_selector("span", text: "Cancel Order") - page.find("span", text: "Cancel Order").click + context "from order's payments" do + before do + visit spree.admin_order_payments_path(order) + find("#links-dropdown .ofn-drop-down").click end - within '.modal-content' do - expect { - find_button("OK").click - }.to change { order.reload.state }.from('complete').to('canceled') + it_behaves_like "canceling an order" + end + + context "from order's adjustments" do + before do + visit spree.admin_order_adjustments_path(order) + find("#links-dropdown .ofn-drop-down").click end + it_behaves_like "canceling an order" end end From 8370d7ce83148a29cce284d6859fedfaf61bc58e Mon Sep 17 00:00:00 2001 From: Mohamed ABDELLANI Date: Sun, 13 Aug 2023 13:12:56 +0100 Subject: [PATCH 2/2] Update app/views/spree/admin/shared/_order_links.html.haml Co-authored-by: jibees --- app/views/spree/admin/shared/_order_links.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/spree/admin/shared/_order_links.html.haml b/app/views/spree/admin/shared/_order_links.html.haml index 195b111f27..6afd99bac2 100644 --- a/app/views/spree/admin/shared/_order_links.html.haml +++ b/app/views/spree/admin/shared/_order_links.html.haml @@ -11,4 +11,4 @@ %i{ class: link[:icon] } %span=link[:name] -= render 'spree/admin/shared/custom-confirm' \ No newline at end of file += render 'spree/admin/shared/custom-confirm'