Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/forum/backends/mysql/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -940,7 +940,7 @@ def threads_presentor(
is_read, unread_count = read_states.get(
str(thread.pk), (False, thread.comment_count)
)
is_endorsed = threads_endorsed.get(thread.pk, False)
is_endorsed = threads_endorsed.get(str(thread.pk), False)
abuse_flagged_count = threads_flagged.get(str(thread.pk), 0)
presenters.append(
cls.prepare_thread(
Expand Down
23 changes: 23 additions & 0 deletions tests/test_views/test_threads.py
Original file line number Diff line number Diff line change
Expand Up @@ -650,6 +650,29 @@ def test_computes_endorsed_correctly(
assert thread["endorsed"] is True


def test_computes_endorsed_correctly_in_thread_list(
api_client: APIClient, patched_get_backend: Any
) -> None:
"""Test computes endorsed correctly through the thread list API."""
backend = patched_get_backend
_, thread_id = setup_models(backend)
comment_id = backend.create_comment(
{
"body": "Comment 1",
"course_id": "course1",
"author_id": "1",
"comment_thread_id": thread_id,
"author_username": "user1",
}
)
backend.update_comment(comment_id=comment_id, endorsed=True)
response = api_client.get_json("/api/v2/threads", {"course_id": "course1"})
assert response.status_code == 200
results = response.json().get("collection", [])
assert len(results) == 1
assert results[0]["endorsed"] is True


def test_no_children_for_informational_request(
api_client: APIClient, patched_get_backend: Any
) -> None:
Expand Down