mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Add unconfirmed scope
This commit is contained in:
@@ -62,6 +62,7 @@ class Enterprise < ActiveRecord::Base
|
||||
scope :by_name, order('name')
|
||||
scope :visible, where(:visible => true)
|
||||
scope :confirmed, where('confirmed_at IS NOT NULL')
|
||||
scope :unconfirmed, where('confirmed_at IS NULL')
|
||||
scope :is_primary_producer, where(:is_primary_producer => true)
|
||||
scope :is_distributor, where(:is_distributor => true)
|
||||
scope :supplying_variant_in, lambda { |variants| joins(:supplied_products => :variants_including_master).where('spree_variants.id IN (?)', variants).select('DISTINCT enterprises.*') }
|
||||
|
||||
@@ -132,6 +132,17 @@ describe Enterprise do
|
||||
end
|
||||
end
|
||||
|
||||
describe "unconfirmed" do
|
||||
it "find enterprises without a confirmed date" do
|
||||
s1 = create(:supplier_enterprise, confirmed_at: Time.now)
|
||||
d1 = create(:distributor_enterprise, confirmed_at: Time.now)
|
||||
s2 = create(:supplier_enterprise, confirmed_at: nil)
|
||||
d2 = create(:distributor_enterprise, confirmed_at: nil)
|
||||
expect(Enterprise.unconfirmed).to_not include s1, d1
|
||||
expect(Enterprise.unconfirmed).to include s2, d2
|
||||
end
|
||||
end
|
||||
|
||||
describe "distributors_with_active_order_cycles" do
|
||||
it "finds active distributors by order cycles" do
|
||||
s = create(:supplier_enterprise)
|
||||
|
||||
Reference in New Issue
Block a user