From 722c66069777d85df1bd51197b1ea6cb1b2a2134 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Bellet Date: Tue, 18 Apr 2023 14:36:29 +0200 Subject: [PATCH] Do not show any links to other steps when no distribution set distribution means tuple: distributor + order cycle --- .../spree/admin/shared/_order_tabs.html.haml | 37 ++++++++++--------- spec/system/admin/order_spec.rb | 34 +++++++++++++++++ 2 files changed, 53 insertions(+), 18 deletions(-) diff --git a/app/views/spree/admin/shared/_order_tabs.html.haml b/app/views/spree/admin/shared/_order_tabs.html.haml index 8b46243b08..40cc8e323c 100644 --- a/app/views/spree/admin/shared/_order_tabs.html.haml +++ b/app/views/spree/admin/shared/_order_tabs.html.haml @@ -42,25 +42,26 @@ %dd#date_complete = pretty_time(@order.completed_at) - %nav.menu - %ul - - customer_details_classes = "active" if current == "Customer Details" - %li{ class: customer_details_classes } - = link_to_with_icon 'icon-user', t(:customer_details), spree.admin_order_customer_url(@order) + - if @order.distribution_set? + %nav.menu + %ul + - customer_details_classes = "active" if current == "Customer Details" + %li{ class: customer_details_classes } + = link_to_with_icon 'icon-user', t(:customer_details), spree.admin_order_customer_url(@order) - - order_details_classes = "active" if current == "Order Details" - %li{ class: order_details_classes } - = link_to_with_icon 'icon-edit', t(:order_details), spree.edit_admin_order_url(@order) + - order_details_classes = "active" if current == "Order Details" + %li{ class: order_details_classes } + = link_to_with_icon 'icon-edit', t(:order_details), spree.edit_admin_order_url(@order) - - payments_classes = "active" if current == "Payments" - %li{ class: payments_classes } - = link_to_with_icon 'icon-credit-card', t(:payments), spree.admin_order_payments_url(@order) + - payments_classes = "active" if current == "Payments" + %li{ class: payments_classes } + = link_to_with_icon 'icon-credit-card', t(:payments), spree.admin_order_payments_url(@order) - - adjustments_classes = "active" if current == "Adjustments" - %li{ class: adjustments_classes } - = link_to_with_icon 'icon-cogs', t(:adjustments), spree.admin_order_adjustments_url(@order) + - adjustments_classes = "active" if current == "Adjustments" + %li{ class: adjustments_classes } + = link_to_with_icon 'icon-cogs', t(:adjustments), spree.admin_order_adjustments_url(@order) - - if @order.completed? - - authorizations_classes = "active" if current == "Return Authorizations" - %li{ class: authorizations_classes } - = link_to_with_icon 'icon-share-alt', t(:return_authorizations), spree.admin_order_return_authorizations_url(@order) + - if @order.completed? + - authorizations_classes = "active" if current == "Return Authorizations" + %li{ class: authorizations_classes } + = link_to_with_icon 'icon-share-alt', t(:return_authorizations), spree.admin_order_return_authorizations_url(@order) diff --git a/spec/system/admin/order_spec.rb b/spec/system/admin/order_spec.rb index 3b932aec74..96211327b5 100644 --- a/spec/system/admin/order_spec.rb +++ b/spec/system/admin/order_spec.rb @@ -109,6 +109,40 @@ describe ' expect(page).to have_content "Order cycle can't be blank" end + + it "doesn't show links to other steps" do + expect(page).not_to have_content "CUSTOMER DETAILS" + expect(page).not_to have_content "ORDER DETAILS" + expect(page).not_to have_content "PAYMENTS" + expect(page).not_to have_content "ADJUSTMENTS" + end + end + + context "when order has a distributor and order cycle" do + before do + order.distributor = distributor + order.order_cycle = order_cycle + order.save! + login_as_admin + visit spree.distribution_admin_order_path(order) + end + + it "can access the `/distribution` step" do + expect(current_path).to eq spree.distribution_admin_order_path(order) + expect(page).to have_content "DISTRIBUTION" + end + + it "shows the distributor and order cycle" do + expect(page).to have_content distributor.name + expect(page).to have_content order_cycle.name + end + + it "shows links to other steps" do + expect(page).to have_content "CUSTOMER DETAILS" + expect(page).to have_content "ORDER DETAILS" + expect(page).to have_content "PAYMENTS" + expect(page).to have_content "ADJUSTMENTS" + end end it "can add a product to an existing order" do