mirror of
https://github.com/zulip/zulip.git
synced 2025-11-02 13:03:29 +00:00
settings: Correctly handle passing empty anonymous group.
If empty anonymous group is passed for a setting value in an API request, the setting is set to "Nobody" group.
This commit is contained in:
@@ -708,6 +708,28 @@ class TestCreateStreams(ZulipTestCase):
|
||||
# testing another setting value.
|
||||
stream.delete()
|
||||
|
||||
nobody_group = NamedUserGroup.objects.get(
|
||||
name="role:nobody", is_system_group=True, realm=realm
|
||||
)
|
||||
|
||||
subscriptions = [{"name": "new_stream", "description": "New stream"}]
|
||||
extra_post_data[setting_name] = orjson.dumps(
|
||||
{"direct_members": [], "direct_subgroups": []}
|
||||
).decode()
|
||||
result = self.subscribe_via_post(
|
||||
user,
|
||||
subscriptions,
|
||||
extra_post_data,
|
||||
allow_fail=True,
|
||||
subdomain="zulip",
|
||||
)
|
||||
self.assert_json_success(result)
|
||||
stream = get_stream("new_stream", realm)
|
||||
self.assertEqual(getattr(stream, setting_name).id, nobody_group.id)
|
||||
# Delete the created stream, so we can create a new one for
|
||||
# testing another setting value.
|
||||
stream.delete()
|
||||
|
||||
subscriptions = [{"name": "new_stream", "description": "New stream"}]
|
||||
owners_group = NamedUserGroup.objects.get(
|
||||
name="role:owners", is_system_group=True, realm=realm
|
||||
@@ -728,9 +750,6 @@ class TestCreateStreams(ZulipTestCase):
|
||||
stream.delete()
|
||||
|
||||
subscriptions = [{"name": "new_stream", "description": "New stream"}]
|
||||
nobody_group = NamedUserGroup.objects.get(
|
||||
name="role:nobody", is_system_group=True, realm=realm
|
||||
)
|
||||
extra_post_data[setting_name] = orjson.dumps(nobody_group.id).decode()
|
||||
result = self.subscribe_via_post(
|
||||
user,
|
||||
|
||||
Reference in New Issue
Block a user