mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-18 04:39:14 +00:00
Adding an active scope and test to Enterprise
This commit is contained in:
@@ -30,6 +30,7 @@ class Enterprise < ActiveRecord::Base
|
||||
after_validation :geocode_address
|
||||
|
||||
scope :by_name, order('name')
|
||||
scope :active, where(:active => true)
|
||||
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.*') }
|
||||
|
||||
@@ -47,6 +47,14 @@ describe Enterprise do
|
||||
end
|
||||
|
||||
describe "scopes" do
|
||||
|
||||
describe 'active' do
|
||||
it 'find active enterprises' do
|
||||
d1 = create(:distributor_enterprise, active: false)
|
||||
s1 = create(:supplier_enterprise)
|
||||
Enterprise.active.should == [s1]
|
||||
end
|
||||
end
|
||||
|
||||
describe "distributors_with_active_order_cycles" do
|
||||
it "finds active distributors by order cycles" do
|
||||
|
||||
Reference in New Issue
Block a user