Commit bd78a26d by Rocky Duan

order comments by time

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