Merge pull request #3034 from evazion/fix-comment-order

Fix /comments.json returning results in undefined order.
This commit is contained in:
Albert Yi
2017-05-10 15:21:52 -07:00
committed by GitHub
2 changed files with 7 additions and 1 deletions

View File

@@ -209,6 +209,13 @@ class CommentTest < ActiveSupport::TestCase
assert_equal(c1.id, matches.all[1].id)
end
should "default to id_desc order when searched with no options specified" do
comms = FactoryGirl.create_list(:comment, 3)
matches = Comment.search({})
assert_equal([comms[2].id, comms[1].id, comms[0].id], matches.map(&:id))
end
context "that is edited by a moderator" do
setup do
@post = FactoryGirl.create(:post)