mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +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):
|
||||
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
|
||||
|
||||
|
||||
|
@ -335,6 +335,7 @@ def create_missing_rule_sets(sender, instance, **kwargs):
|
||||
group permissions.
|
||||
"""
|
||||
created = kwargs.get('created', False)
|
||||
# To trigger the group permissions update: update_fields should not be None
|
||||
update_fields = kwargs.get('update_fields', None)
|
||||
|
||||
if created or update_fields:
|
||||
|
@ -137,7 +137,8 @@ class RuleSetModelTest(TestCase):
|
||||
|
||||
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
|
||||
self.assertEqual(group.permissions.count(), 3 * len(permission_set))
|
||||
@ -151,7 +152,8 @@ class RuleSetModelTest(TestCase):
|
||||
|
||||
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
|
||||
self.assertEqual(group.permissions.count(), 0)
|
||||
|
Loading…
Reference in New Issue
Block a user