fix: save notification state for unchanged comments

When we edit a comment we can enable notifications (if not yet enabled).

We should also do this when the comment text is not changed.

Signed-off-by: moson-mo <mo-son@mailbox.org>
This commit is contained in:
moson-mo 2023-01-22 16:32:39 +01:00
parent 36fd58d7a6
commit ff0123b54a
No known key found for this signature in database
GPG key ID: 4A4760AB4EE15296
2 changed files with 24 additions and 1 deletions

View file

@ -512,6 +512,26 @@ def test_pkgbase_comments(
).first()
assert db_notif is not None
# Delete notification for next test.
with db.begin():
db.delete(db_notif)
# Let's edit the comment again; This time we don't change the text.
# However we do enable notifications.
with client as request:
request.cookies = cookies
resp = request.post(
endpoint,
data={"comment": "Edited comment.", "enable_notifications": True},
)
assert resp.status_code == int(HTTPStatus.SEE_OTHER)
# Ensure that a notification was created.
db_notif = pkgbase.notifications.filter(
PackageNotification.UserID == maintainer.ID
).first()
assert db_notif is not None
# Don't supply a comment; should return BAD_REQUEST.
with client as request:
request.cookies = cookies