mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
Construct enterprise relationships with a factory
This commit is contained in:
@@ -96,6 +96,9 @@ FactoryGirl.define do
|
||||
is_distributor true
|
||||
end
|
||||
|
||||
factory :enterprise_relationship do
|
||||
end
|
||||
|
||||
factory :enterprise_group, :class => EnterpriseGroup do
|
||||
name 'Enterprise group'
|
||||
description 'this is a group'
|
||||
|
||||
@@ -31,10 +31,10 @@ describe Enterprise do
|
||||
let(:e) { create(:distributor_enterprise) }
|
||||
let(:p) { create(:supplier_enterprise) }
|
||||
let(:c) { create(:distributor_enterprise) }
|
||||
before do
|
||||
EnterpriseRelationship.create! parent_id: p.id, child_id: e.id
|
||||
EnterpriseRelationship.create! parent_id: e.id, child_id: c.id
|
||||
end
|
||||
|
||||
let!(:er1) { create(:enterprise_relationship, parent_id: p.id, child_id: e.id) }
|
||||
let!(:er2) { create(:enterprise_relationship, parent_id: e.id, child_id: c.id) }
|
||||
|
||||
it "finds relatives" do
|
||||
e.relatives.sort.should == [p, c].sort
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user