mirror of https://github.com/zulip/zulip.git
Return a JSON error on an invalid zephyr type.
(imported from commit 2207464c368666715caf550f32136de45ea37142)
This commit is contained in:
parent
b235b8bc31
commit
13e5b45815
|
@ -330,3 +330,11 @@ class ZephyrPOSTTest(AuthedTestCase):
|
||||||
"new_zephyr": "Test message",
|
"new_zephyr": "Test message",
|
||||||
"recipient": "nonexistent"})
|
"recipient": "nonexistent"})
|
||||||
self.assert_json_error(result, "Invalid username")
|
self.assert_json_error(result, "Invalid username")
|
||||||
|
|
||||||
|
def test_invalid_type(self):
|
||||||
|
"""
|
||||||
|
Sending a zephyr of unknown type returns error JSON.
|
||||||
|
"""
|
||||||
|
self.login("hamlet", "hamlet")
|
||||||
|
result = self.client.post("/zephyr/", {"type": "invalid type"})
|
||||||
|
self.assert_json_error(result, "Invalid zephyr type")
|
||||||
|
|
|
@ -210,8 +210,7 @@ def zephyr_backend(request, sender):
|
||||||
recipient_user_profile = UserProfile.objects.get(user=recipient_user)
|
recipient_user_profile = UserProfile.objects.get(user=recipient_user)
|
||||||
recipient = Recipient.objects.get(type_id=recipient_user_profile.id, type="personal")
|
recipient = Recipient.objects.get(type_id=recipient_user_profile.id, type="personal")
|
||||||
else:
|
else:
|
||||||
# Do something smarter here
|
return json_error("Invalid zephyr type")
|
||||||
raise
|
|
||||||
|
|
||||||
new_zephyr = Zephyr()
|
new_zephyr = Zephyr()
|
||||||
new_zephyr.sender = UserProfile.objects.get(user=sender)
|
new_zephyr.sender = UserProfile.objects.get(user=sender)
|
||||||
|
|
Loading…
Reference in New Issue