settings: Add group_creator as default for can_manage_group.

We create an unnamed user group with just the group creator as it's
member when trying to set the default. The pattern I've followed across
most of the acting_user additions is to just put the user declared
somewhere before the check_add_user_group and see if the test passes.
If it does not, then I'll look at what kind of user it needs to be set
to `acting_user`.
This commit is contained in:
Shubham Padia
2024-09-25 09:51:28 +00:00
committed by Tim Abbott
parent 91edf59873
commit 12ebd97f1f
24 changed files with 162 additions and 109 deletions

View File

@@ -1832,13 +1832,13 @@ class NormalActionsTest(BaseAction):
othello = self.example_user("othello")
with self.verify_action() as events:
check_add_user_group(
self.user_profile.realm, "backend", [othello], "Backend team", acting_user=None
self.user_profile.realm, "backend", [othello], "Backend team", acting_user=othello
)
check_user_group_add("events[0]", events[0])
nobody_group = NamedUserGroup.objects.get(
name=SystemGroups.NOBODY, realm=self.user_profile.realm, is_system_group=True
self.assertEqual(
events[0]["group"]["can_manage_group"],
AnonymousSettingGroupDict(direct_members=[12], direct_subgroups=[]),
)
self.assertEqual(events[0]["group"]["can_manage_group"], nobody_group.id)
everyone_group = NamedUserGroup.objects.get(
name=SystemGroups.EVERYONE, realm=self.user_profile.realm, is_system_group=True
)
@@ -1857,7 +1857,7 @@ class NormalActionsTest(BaseAction):
[othello],
"",
{"can_manage_group": user_group, "can_mention_group": user_group},
acting_user=None,
acting_user=othello,
)
check_user_group_add("events[0]", events[0])
self.assertEqual(
@@ -1930,7 +1930,7 @@ class NormalActionsTest(BaseAction):
check_user_group_remove_members("events[0]", events[0])
api_design = check_add_user_group(
hamlet.realm, "api-design", [hamlet], description="API design team", acting_user=None
hamlet.realm, "api-design", [hamlet], description="API design team", acting_user=othello
)
# Test add subgroups