mirror of
https://github.com/inventree/InvenTree.git
synced 2025-04-30 04:26:44 +00:00
Fixed permission assign test unit
This commit is contained in:
parent
c910307ce5
commit
d980da7247
@ -101,6 +101,7 @@ class RoleGroupAdmin(admin.ModelAdmin):
|
|||||||
|
|
||||||
def save_formset(self, request, form, formset, change):
|
def save_formset(self, request, form, formset, change):
|
||||||
formset.save() # this will save the children
|
formset.save() # this will save the children
|
||||||
|
# update_fields is required to trigger permissions update
|
||||||
form.instance.save(update_fields=['name']) # form.instance is the parent
|
form.instance.save(update_fields=['name']) # form.instance is the parent
|
||||||
|
|
||||||
|
|
||||||
|
@ -335,6 +335,7 @@ def create_missing_rule_sets(sender, instance, **kwargs):
|
|||||||
group permissions.
|
group permissions.
|
||||||
"""
|
"""
|
||||||
created = kwargs.get('created', False)
|
created = kwargs.get('created', False)
|
||||||
|
# To trigger the group permissions update: update_fields should not be None
|
||||||
update_fields = kwargs.get('update_fields', None)
|
update_fields = kwargs.get('update_fields', None)
|
||||||
|
|
||||||
if created or update_fields:
|
if created or update_fields:
|
||||||
|
@ -137,7 +137,8 @@ class RuleSetModelTest(TestCase):
|
|||||||
|
|
||||||
rule.save()
|
rule.save()
|
||||||
|
|
||||||
group.save()
|
# update_fields is required to trigger permissions update
|
||||||
|
group.save(update_fields=['name'])
|
||||||
|
|
||||||
# There should now be three permissions for each rule set
|
# There should now be three permissions for each rule set
|
||||||
self.assertEqual(group.permissions.count(), 3 * len(permission_set))
|
self.assertEqual(group.permissions.count(), 3 * len(permission_set))
|
||||||
@ -151,7 +152,8 @@ class RuleSetModelTest(TestCase):
|
|||||||
|
|
||||||
rule.save()
|
rule.save()
|
||||||
|
|
||||||
group.save()
|
# update_fields is required to trigger permissions update
|
||||||
|
group.save(update_fields=['name'])
|
||||||
|
|
||||||
# There should now not be any permissions assigned to this group
|
# There should now not be any permissions assigned to this group
|
||||||
self.assertEqual(group.permissions.count(), 0)
|
self.assertEqual(group.permissions.count(), 0)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user