Fix #4193: Wiki tags for related tags are no longer in wiki order.
This commit is contained in:
@@ -206,8 +206,9 @@ class WikiPage < ApplicationRecord
|
|||||||
end
|
end
|
||||||
|
|
||||||
def tags
|
def tags
|
||||||
titles = DText.parse_wiki_titles(body)
|
titles = DText.parse_wiki_titles(body).uniq
|
||||||
Tag.nonempty.where(name: titles.uniq).pluck(:name)
|
tags = Tag.nonempty.where(name: titles).pluck(:name)
|
||||||
|
titles & tags
|
||||||
end
|
end
|
||||||
|
|
||||||
def visible?
|
def visible?
|
||||||
|
|||||||
@@ -91,6 +91,13 @@ class RelatedTagQueryTest < ActiveSupport::TestCase
|
|||||||
should "find any tags embedded in the wiki page" do
|
should "find any tags embedded in the wiki page" do
|
||||||
assert_equal(["bbb", "ccc"], @query.wiki_page_tags)
|
assert_equal(["bbb", "ccc"], @query.wiki_page_tags)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
should "return the tags in the same order as given by the wiki" do
|
||||||
|
create(:wiki_page, title: "wiki", body: "[[ccc]] [[bbb]] [[ccc]] [[bbb]] [[aaa]]")
|
||||||
|
|
||||||
|
query = RelatedTagQuery.new(query: "wiki")
|
||||||
|
assert_equal(%w[ccc bbb aaa], query.wiki_page_tags)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user