mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-04-04 07:09:14 +00:00
Admin can grant create_variant_overrides permission
This commit is contained in:
@@ -5,6 +5,7 @@ angular.module("ofn.admin").factory 'EnterpriseRelationships', ($http, enterpris
|
||||
'add_to_order_cycle'
|
||||
'manage_products'
|
||||
'edit_profile'
|
||||
'create_variant_overrides'
|
||||
]
|
||||
|
||||
constructor: ->
|
||||
@@ -28,3 +29,4 @@ angular.module("ofn.admin").factory 'EnterpriseRelationships', ($http, enterpris
|
||||
when "add_to_order_cycle" then "to add to order cycle"
|
||||
when "manage_products" then "to manage products"
|
||||
when "edit_profile" then "to edit profile"
|
||||
when "create_variant_overrides" then "to override variant details"
|
||||
|
||||
@@ -373,7 +373,8 @@ class Enterprise < ActiveRecord::Base
|
||||
child: hub,
|
||||
permissions_list: [:add_to_order_cycle,
|
||||
:manage_products,
|
||||
:edit_profile])
|
||||
:edit_profile,
|
||||
:create_variant_overrides])
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -43,13 +43,14 @@ feature %q{
|
||||
check 'to manage products'
|
||||
uncheck 'to manage products'
|
||||
check 'to edit profile'
|
||||
check 'to override variant details'
|
||||
select 'Two', from: 'enterprise_relationship_child_id'
|
||||
click_button 'Create'
|
||||
|
||||
page.should have_relationship e1, e2, ['to add to order cycle', 'to edit profile']
|
||||
page.should have_relationship e1, e2, ['to add to order cycle', 'to override variant details', 'to edit profile']
|
||||
er = EnterpriseRelationship.where(parent_id: e1, child_id: e2).first
|
||||
er.should be_present
|
||||
er.permissions.map(&:name).sort.should == ['add_to_order_cycle', 'edit_profile'].sort
|
||||
er.permissions.map(&:name).sort.should == ['add_to_order_cycle', 'edit_profile', 'create_variant_overrides'].sort
|
||||
end
|
||||
|
||||
|
||||
|
||||
@@ -15,3 +15,4 @@ describe "enterprise relationships", ->
|
||||
expect(EnterpriseRelationships.permission_presentation("add_to_order_cycle")).toEqual "to add to order cycle"
|
||||
expect(EnterpriseRelationships.permission_presentation("manage_products")).toEqual "to manage products"
|
||||
expect(EnterpriseRelationships.permission_presentation("edit_profile")).toEqual "to edit profile"
|
||||
expect(EnterpriseRelationships.permission_presentation("create_variant_overrides")).toEqual "to override variant details"
|
||||
|
||||
@@ -613,7 +613,7 @@ describe Enterprise do
|
||||
|
||||
[er1, er2].each do |er|
|
||||
er.parent.should == enterprise
|
||||
er.permissions.map(&:name).sort.should == ['add_to_order_cycle', 'manage_products', 'edit_profile'].sort
|
||||
er.permissions.map(&:name).sort.should == ['add_to_order_cycle', 'manage_products', 'edit_profile', 'create_variant_overrides'].sort
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user