Skip to content

Commit

Permalink
Do not show any links to other steps when no distribution set
Browse files Browse the repository at this point in the history
distribution means tuple: distributor + order cycle
  • Loading branch information
jibees committed Apr 18, 2023
1 parent ac666a6 commit 722c660
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 18 deletions.
37 changes: 19 additions & 18 deletions app/views/spree/admin/shared/_order_tabs.html.haml
Expand Up @@ -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)
34 changes: 34 additions & 0 deletions spec/system/admin/order_spec.rb
Expand Up @@ -109,6 +109,40 @@ def new_order_with_distribution(distributor, order_cycle)

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
Expand Down

0 comments on commit 722c660

Please sign in to comment.