diff --git a/app/models/spree/order.rb b/app/models/spree/order.rb index 707449af4a..ad84f5e6b7 100644 --- a/app/models/spree/order.rb +++ b/app/models/spree/order.rb @@ -361,6 +361,10 @@ module Spree complete? || resumed? || awaiting_return? || returned? end + def can_show_invoice? + complete? || resumed? || canceled? + end + # Finalizes an in progress order after checkout is complete. # Called after transition to complete state when payments will have been processed def finalize! diff --git a/app/views/spree/admin/shared/_order_tabs.html.haml b/app/views/spree/admin/shared/_order_tabs.html.haml index 78d6b18c95..1c89c24f1f 100644 --- a/app/views/spree/admin/shared/_order_tabs.html.haml +++ b/app/views/spree/admin/shared/_order_tabs.html.haml @@ -61,7 +61,7 @@ %li{ class: adjustments_classes } = link_to_with_icon 'icon-cogs', t(:adjustments), spree.admin_order_adjustments_url(@order) - - if feature?(:invoices) + - if feature?(:invoices) && @order.can_show_invoice? - invoices_classes = "active" if current == 'Invoices' %li{ class: invoices_classes } = link_to_with_icon 'icon-cogs', t(:invoices), spree.admin_order_invoices_url(@order) diff --git a/spec/system/admin/order_spec.rb b/spec/system/admin/order_spec.rb index 93acf8be30..81727b48ee 100644 --- a/spec/system/admin/order_spec.rb +++ b/spec/system/admin/order_spec.rb @@ -1123,8 +1123,7 @@ describe ' visit spree.edit_admin_order_path(order_empty) end - it "displays the invoice tab" do - pending "issue #11240" + it "should not display the invoice tab" do expect(page).to have_content "Cart".upcase expect(page).not_to have_content "Invoices".upcase end @@ -1140,8 +1139,7 @@ describe ' visit spree.edit_admin_order_path(order4) end - it "displays the invoice tab" do - pending "issue #11240" + it "should not display the invoice tab" do expect(page).to have_content "Payment".upcase expect(page).not_to have_content "Invoices".upcase end