The Resend Confirmation and Send/Print Invoice links should display for resumed orders too

These are links inside the Actions drop down menu on the edit order view. Before they were missing if an order was in a resumed state.

Fixes #5946
This commit is contained in:
Cillian O'Ruanaidh
2021-04-02 15:41:59 +01:00
parent d7cadde0a1
commit 7e2d9ff381
2 changed files with 33 additions and 6 deletions

View File

@@ -16,7 +16,7 @@ module Spree
@order ||= order
links = []
links << edit_order_link unless action_name == "edit"
links.concat(complete_order_links) if @order.complete?
links.concat(complete_order_links) if @order.complete? || @order.resumed?
links << ship_order_link if @order.ready_to_ship?
links << cancel_order_link if @order.can_cancel?
links

View File

@@ -19,6 +19,7 @@ describe Spree::Admin::OrdersHelper, type: :helper do
allow(order).to receive(:complete?) { false }
allow(order).to receive(:ready_to_ship?) { false }
allow(order).to receive(:can_cancel?) { false }
allow(order).to receive(:resumed?) { false }
Spree::Config[:enable_invoices?] = false
Spree::Config[:enable_receipt_printing?] = false
end
@@ -71,11 +72,7 @@ describe Spree::Admin::OrdersHelper, type: :helper do
end
context "with invoices enabled" do
before do
Spree::Config[:enable_invoices?] = true
allow(order).to receive(:distributor) { distributor }
allow(distributor).to receive(:can_invoice?) { true }
end
before { enable_invoices }
it "adds send and print invoice links" do
links = helper.order_links(order)
@@ -100,5 +97,35 @@ describe Spree::Admin::OrdersHelper, type: :helper do
end
end
end
context "resumed order" do
before { allow(order).to receive(:resumed?) { true } }
it "includes a resend confirmation link" do
links = helper.order_links(order).map { |link| link[:name] }
expect(links).to match_array(["Edit Order", "Resend Confirmation"])
end
context "with invoices enabled" do
before { enable_invoices }
it "includes send invoice and print invoice links" do
links = helper.order_links(order).map { |link| link[:name] }
expect(links).to match_array(
["Edit Order", "Print Invoice", "Resend Confirmation", "Send Invoice"]
)
end
end
end
end
private
def enable_invoices
Spree::Config[:enable_invoices?] = true
allow(order).to receive(:distributor) { distributor }
allow(distributor).to receive(:can_invoice?) { true }
end
end