diff --git a/lib/open_food_network/lettuce_share_report.rb b/lib/open_food_network/lettuce_share_report.rb index 8f862efee8..97b1f058fc 100644 --- a/lib/open_food_network/lettuce_share_report.rb +++ b/lib/open_food_network/lettuce_share_report.rb @@ -25,7 +25,7 @@ module OpenFoodNetwork scoper = OpenFoodNetwork::ScopeVariantToHub.new(distributor) variants.each { |v| scoper.scope(v) } end - variants.select { |v| v.count_on_hand > 0 } + variants.select { |v| v.in_stock? } .map do |variant| [ variant.product.name, diff --git a/spec/lib/open_food_network/lettuce_share_report_spec.rb b/spec/lib/open_food_network/lettuce_share_report_spec.rb index 5b54a8aec8..258af03c90 100644 --- a/spec/lib/open_food_network/lettuce_share_report_spec.rb +++ b/spec/lib/open_food_network/lettuce_share_report_spec.rb @@ -36,6 +36,7 @@ module OpenFoodNetwork describe "lists" do let(:v2) { create(:variant) } let(:v3) { create(:variant) } + let(:v4) { create(:variant, count_on_hand: 0, on_demand: true) } let(:hub_address) { create(:address, :address1 => "distributor address", :city => 'The Shire', :zipcode => "1234") } let(:hub) { create(:distributor_enterprise, :address => hub_address) } let(:v2o) { create(:variant_override, hub: hub, variant: v2) } @@ -47,9 +48,9 @@ module OpenFoodNetwork end it "only available items" do - report.stub(:variants) { [v, v2, v3] } + report.stub(:variants) { [v, v2, v3, v4] } v.count_on_hand = 0 - report.send(:table).count.should eq 2 + report.send(:table).count.should eq 3 end it "only available items considering overrides" do