fix: Fix middleware checking for accepted terms

The current query is a bit mixed up. The intention was to return the
number of unaccepted records. Now it does also count all records
that were accepted by some other user though.

Let's check the total number of terms vs. the number of accepted
records (by our user) instead.

Signed-off-by: moson <moson@archlinux.org>
This commit is contained in:
moson 2023-07-20 18:21:05 +02:00
parent 5729d6787f
commit bc03d8b8f2
No known key found for this signature in database
GPG key ID: 4A4760AB4EE15296
2 changed files with 14 additions and 11 deletions

View file

@ -1915,6 +1915,12 @@ def test_get_terms_of_service(client: TestClient, user: User):
# We accepted the term, there's nothing left to accept.
assert response.status_code == int(HTTPStatus.SEE_OTHER)
# Make sure we don't get redirected to /tos when browsing "Home"
with client as request:
request.cookies = cookies
response = request.get("/")
assert response.status_code == int(HTTPStatus.OK)
# Bump the term's revision.
with db.begin():
term.Revision = 2