Merge pull request #2991 from evazion/fix-2990

Fix #2990: Wiki Autocomplete Misses On Certain Meta-wikis
This commit is contained in:
Albert Yi
2017-04-24 14:12:23 -07:00
committed by GitHub
3 changed files with 7 additions and 2 deletions

View File

@@ -437,7 +437,7 @@ class Artist < ActiveRecord::Base
when "updated_at"
q = q.order("artists.updated_at desc")
when "post_count"
q = q.joins(:tag).order("tags.post_count desc")
q = q.includes(:tag).order("tags.post_count desc nulls last").references(:tags)
else
q = q.order("artists.id desc")
end

View File

@@ -87,7 +87,7 @@ class WikiPage < ActiveRecord::Base
when "title"
q = q.order("title")
when "post_count"
q = q.joins(:tag).order("tags.post_count desc")
q = q.includes(:tag).order("tags.post_count desc nulls last").references(:tags)
else
q = q.order("updated_at desc")
end

View File

@@ -28,6 +28,11 @@ class WikiPagesControllerTest < ActionController::TestCase
get :index, {:search => {:title => "abc"}}
assert_redirected_to(wiki_page_path(@wiki_page_abc))
end
should "list wiki_pages without tags with order=post_count" do
get :index, {:search => {:title => "abc", :order => "post_count"}}
assert_redirected_to(wiki_page_path(@wiki_page_abc))
end
end
context "show action" do