Skip to content

Commit 5e13292

Browse files
author
Greg Price
committed
Merge pull request #129 from edx/gprice/comment-return-parent-id
Return comment parent_id field
2 parents fdf017c + 0487891 commit 5e13292

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

models/comment.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ def to_hash(params={})
102102
.merge("depth" => depth)
103103
.merge("closed" => comment_thread.nil? ? false : comment_thread.closed) # ditto
104104
.merge("thread_id" => comment_thread_id)
105+
.merge("parent_id" => parent_ids[-1])
105106
.merge("commentable_id" => comment_thread.nil? ? nil : comment_thread.commentable_id) # ditto
106107
.merge("votes" => votes.slice(*%w[count up_count down_count point]))
107108
.merge("abuse_flaggers" => abuse_flaggers)

spec/api/comment_spec.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
retrieved["children"].should be_nil
2626
retrieved["votes"]["point"].should == comment.votes_point
2727
retrieved["depth"].should == comment.depth
28+
retrieved["parent_id"].should == comment.parent_ids[-1]
2829
end
2930
it "retrieve information of a single comment with its sub comments" do
3031
comment = Comment.first
@@ -37,6 +38,7 @@
3738
retrieved["votes"]["point"].should == comment.votes_point
3839
retrieved["children"].length.should == comment.children.length
3940
retrieved["children"].select{|c| c["body"] == comment.children.first.body}.first.should_not be_nil
41+
retrieved["children"].each{|c| c["parent_id"].should == comment.id.to_s}
4042
end
4143
it "returns 400 when the comment does not exist" do
4244
get "/api/v1/comments/does_not_exist"

0 commit comments

Comments
 (0)