Merge pull request #3034 from evazion/fix-comment-order
Fix /comments.json returning results in undefined order.
This commit is contained in:
@@ -86,7 +86,6 @@ class Comment < ActiveRecord::Base
|
|||||||
|
|
||||||
def search(params)
|
def search(params)
|
||||||
q = where("true")
|
q = where("true")
|
||||||
return q if params.blank?
|
|
||||||
|
|
||||||
if params[:body_matches].present?
|
if params[:body_matches].present?
|
||||||
q = q.body_matches(params[:body_matches])
|
q = q.body_matches(params[:body_matches])
|
||||||
|
|||||||
@@ -209,6 +209,13 @@ class CommentTest < ActiveSupport::TestCase
|
|||||||
assert_equal(c1.id, matches.all[1].id)
|
assert_equal(c1.id, matches.all[1].id)
|
||||||
end
|
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
|
context "that is edited by a moderator" do
|
||||||
setup do
|
setup do
|
||||||
@post = FactoryGirl.create(:post)
|
@post = FactoryGirl.create(:post)
|
||||||
|
|||||||
Reference in New Issue
Block a user