mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
implement Spree::Order#invoiceable?
This will be used to filter the orders when running bulk print
This commit is contained in:
@@ -208,6 +208,10 @@ module Spree
|
||||
completed_at.present?
|
||||
end
|
||||
|
||||
def invoiceable?
|
||||
complete? || resumed?
|
||||
end
|
||||
|
||||
# Indicates whether or not the user is allowed to proceed to checkout.
|
||||
# Currently this is implemented as a check for whether or not there is at
|
||||
# least one LineItem in the Order. Feel free to override this logic in your
|
||||
|
||||
@@ -140,6 +140,23 @@ describe Spree::Order do
|
||||
end
|
||||
end
|
||||
|
||||
context "#invoiceable?" do
|
||||
it "should return true if the order is completed" do
|
||||
allow(order).to receive_messages(complete?: true)
|
||||
expect(order.invoiceable?).to be_truthy
|
||||
end
|
||||
|
||||
it "should return true if the order is resumed" do
|
||||
allow(order).to receive_messages(resumed?: true)
|
||||
expect(order.invoiceable?).to be_truthy
|
||||
end
|
||||
|
||||
it "should return false if the order is neither completed nor resumed" do
|
||||
allow(order).to receive_messages(complete?: false, resumed?: false)
|
||||
expect(order.invoiceable?).to be_falsy
|
||||
end
|
||||
end
|
||||
|
||||
context "checking if order is paid" do
|
||||
context "payment_state is paid" do
|
||||
before { allow(order).to receive_messages payment_state: 'paid' }
|
||||
|
||||
Reference in New Issue
Block a user