Construct enterprise relationships with a factory

This commit is contained in:
Rohan Mitchell
2014-05-15 12:19:07 +10:00
parent 391b1da04c
commit 4f1b8d06e7
2 changed files with 7 additions and 4 deletions

View File

@@ -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'

View File

@@ -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