Commit 5e13292e by Greg Price

Merge pull request #129 from edx/gprice/comment-return-parent-id

Return comment parent_id field
parents fdf017c9 04878910
......@@ -102,6 +102,7 @@ class Comment < Content
.merge("depth" => depth)
.merge("closed" => comment_thread.nil? ? false : comment_thread.closed) # ditto
.merge("thread_id" => comment_thread_id)
.merge("parent_id" => parent_ids[-1])
.merge("commentable_id" => comment_thread.nil? ? nil : comment_thread.commentable_id) # ditto
.merge("votes" => votes.slice(*%w[count up_count down_count point]))
.merge("abuse_flaggers" => abuse_flaggers)
......
......@@ -25,6 +25,7 @@ describe "app" do
retrieved["children"].should be_nil
retrieved["votes"]["point"].should == comment.votes_point
retrieved["depth"].should == comment.depth
retrieved["parent_id"].should == comment.parent_ids[-1]
end
it "retrieve information of a single comment with its sub comments" do
comment = Comment.first
......@@ -37,6 +38,7 @@ describe "app" do
retrieved["votes"]["point"].should == comment.votes_point
retrieved["children"].length.should == comment.children.length
retrieved["children"].select{|c| c["body"] == comment.children.first.body}.first.should_not be_nil
retrieved["children"].each{|c| c["parent_id"].should == comment.id.to_s}
end
it "returns 400 when the comment does not exist" do
get "/api/v1/comments/does_not_exist"
......
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