mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
Add OrderCycle#supplied_variants
This commit is contained in:
@@ -135,6 +135,10 @@ class OrderCycle < ActiveRecord::Base
|
||||
to_a # http://stackoverflow.com/q/15110166
|
||||
end
|
||||
|
||||
def supplied_variants
|
||||
self.exchanges.incoming.map(&:variants).flatten.uniq.reject(&:deleted?)
|
||||
end
|
||||
|
||||
def distributed_variants
|
||||
self.exchanges.outgoing.map(&:variants).flatten.uniq.reject(&:deleted?)
|
||||
end
|
||||
|
||||
@@ -211,6 +211,10 @@ describe OrderCycle do
|
||||
@oc.variants.count.should == 4
|
||||
end
|
||||
|
||||
it "reports on the variants supplied" do
|
||||
@oc.supplied_variants.should match_array [@p0.master]
|
||||
end
|
||||
|
||||
it "reports on the variants distributed" do
|
||||
@oc.distributed_variants.should match_array [@p1.master, @p2.master, @p2_v]
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user