mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Enterprise.active_distributors doesn't show distributors of out of stock products
This commit is contained in:
@@ -35,7 +35,7 @@ class Enterprise < ActiveRecord::Base
|
||||
|
||||
scope :active_distributors, lambda {
|
||||
with_distributed_products_outer.with_order_cycles_outer.
|
||||
where('(product_distributions.product_id IS NOT NULL AND spree_products.deleted_at IS NULL AND spree_products.available_on <= ?) OR order_cycles.id IS NOT NULL', Time.now).
|
||||
where('(product_distributions.product_id IS NOT NULL AND spree_products.deleted_at IS NULL AND spree_products.available_on <= ? AND spree_products.count_on_hand > 0) OR order_cycles.id IS NOT NULL', Time.now).
|
||||
select('DISTINCT enterprises.*')
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,11 @@ describe Enterprise do
|
||||
Enterprise.active_distributors.should be_empty
|
||||
end
|
||||
|
||||
it "doesn't show distributors of out of stock products"
|
||||
it "doesn't show distributors of out of stock products" do
|
||||
d = create(:distributor_enterprise)
|
||||
create(:product, :distributors => [d], :on_hand => 0)
|
||||
Enterprise.active_distributors.should be_empty
|
||||
end
|
||||
|
||||
it "finds active distributors by order cycles" do
|
||||
s = create(:supplier_enterprise)
|
||||
|
||||
Reference in New Issue
Block a user