Simplify enterprise_relationship factory - leverage permissions_list= model method

This commit is contained in:
Rohan Mitchell
2014-08-25 15:20:46 +10:00
parent c3224ce668
commit 1a995aedda
2 changed files with 3 additions and 9 deletions

View File

@@ -101,12 +101,6 @@ FactoryGirl.define do
end
factory :enterprise_relationship do
ignore { permissions [] }
after(:create) do |er, proxy|
proxy.permissions.each do |name|
er.permissions.create! name: name
end
end
end
factory :enterprise_role do

View File

@@ -14,9 +14,9 @@ feature %q{
scenario "listing relationships" do
# Given some enterprises with relationships
e1, e2, e3, e4 = create(:enterprise), create(:enterprise), create(:enterprise), create(:enterprise)
create(:enterprise_relationship, parent: e1, child: e2, permissions: [:add_products_to_order_cycle])
create(:enterprise_relationship, parent: e2, child: e3, permissions: [:manage_products])
create(:enterprise_relationship, parent: e3, child: e4, permissions: [:add_products_to_order_cycle, :manage_products])
create(:enterprise_relationship, parent: e1, child: e2, permissions_list: [:add_products_to_order_cycle])
create(:enterprise_relationship, parent: e2, child: e3, permissions_list: [:manage_products])
create(:enterprise_relationship, parent: e3, child: e4, permissions_list: [:add_products_to_order_cycle, :manage_products])
# When I go to the relationships page
click_link 'Enterprises'