Commit 3c48585c by Greg Price

Fix bug in discussion API comment update

This bug caused any attempt to update a comment with a non-null
parent_id to result in a 500 error without applying the update. The bug
was introduced in commit 2c7590d1.
parent 5ceea7a0
......@@ -85,11 +85,7 @@ def _get_comment_and_context(request, comment_id):
"""
try:
cc_comment = Comment(id=comment_id).retrieve()
_, context = _get_thread_and_context(
request,
cc_comment["thread_id"],
cc_comment["parent_id"]
)
_, context = _get_thread_and_context(request, cc_comment["thread_id"])
return cc_comment, context
except CommentClientRequestError:
raise Http404
......
......@@ -1689,13 +1689,14 @@ class UpdateCommentTest(CommentsServiceMockMixin, UrlResetMixin, ModuleStoreTest
for request in httpretty.httpretty.latest_requests:
self.assertEqual(request.method, "GET")
def test_basic(self):
self.register_comment()
@ddt.data(None, "test_parent")
def test_basic(self, parent_id):
self.register_comment({"parent_id": parent_id})
actual = update_comment(self.request, "test_comment", {"raw_body": "Edited body"})
expected = {
"id": "test_comment",
"thread_id": "test_thread",
"parent_id": None, # TODO: we can't get this without retrieving from the thread :-(
"parent_id": parent_id,
"author": self.user.username,
"author_label": None,
"created_at": "2015-06-03T00:00:00Z",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment