Commit bd78a26d by Rocky Duan

order comments by time

parent 685778b1
...@@ -34,7 +34,7 @@ class Comment < ActiveRecord::Base ...@@ -34,7 +34,7 @@ class Comment < ActiveRecord::Base
end end
def to_hash_tree def to_hash_tree
self.class.hash_tree(self.subtree.arrange) self.class.hash_tree(self.subtree.arrange(:order => "updated_at DESC"))
end end
end end
...@@ -89,10 +89,11 @@ describe "app" do ...@@ -89,10 +89,11 @@ describe "app" do
c["created_at"].should_not be_nil c["created_at"].should_not be_nil
c["updated_at"].should_not be_nil c["updated_at"].should_not be_nil
c["children"].length.should == 2 c["children"].length.should == 2
c["children"][0]["title"].should == "comment title 0" children = c["children"].reject{|comment| comment["title"] != "comment title 0"}.first
c["children"][0]["id"].should == sub_comment[0].id children.should_not be_nil
c["children"][0]["created_at"].should_not be_nil children["id"].should == sub_comment[0].id
c["children"][0]["updated_at"].should_not be_nil children["created_at"].should_not be_nil
children["updated_at"].should_not be_nil
end end
end end
describe "DELETE on /api/v1/commentables/:commentable_type/:commentable_id" do describe "DELETE on /api/v1/commentables/:commentable_type/:commentable_id" do
......
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