mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Merge pull request #7030 from Matt-Yorkley/dcotw-item-count
DCOTW: Order#item_count
This commit is contained in:
@@ -220,11 +220,6 @@ module Spree
|
||||
total.to_f > 0.0 && !skip_payment_for_subscription?
|
||||
end
|
||||
|
||||
# Indicates the number of items in the order
|
||||
def item_count
|
||||
line_items.inject(0) { |sum, li| sum + li.quantity }
|
||||
end
|
||||
|
||||
def backordered?
|
||||
shipments.any?(&:backordered?)
|
||||
end
|
||||
|
||||
@@ -289,16 +289,6 @@ describe Spree::Order do
|
||||
end
|
||||
end
|
||||
|
||||
context "#item_count" do
|
||||
before do
|
||||
@order = create(:order, user: user)
|
||||
@order.line_items = [create(:line_item, quantity: 2), create(:line_item, quantity: 1)]
|
||||
end
|
||||
it "should return the correct number of items" do
|
||||
expect(@order.item_count).to eq 3
|
||||
end
|
||||
end
|
||||
|
||||
context "#amount" do
|
||||
before do
|
||||
@order = create(:order, user: user)
|
||||
|
||||
Reference in New Issue
Block a user