Fix #4199: Aliased tags not included in related wiki tags.
This commit is contained in:
@@ -220,7 +220,8 @@ class WikiPage < ApplicationRecord
|
|||||||
def tags
|
def tags
|
||||||
titles = DText.parse_wiki_titles(body).uniq
|
titles = DText.parse_wiki_titles(body).uniq
|
||||||
tags = Tag.nonempty.where(name: titles).pluck(:name)
|
tags = Tag.nonempty.where(name: titles).pluck(:name)
|
||||||
titles & tags
|
tags += TagAlias.active.where(antecedent_name: titles).pluck(:antecedent_name)
|
||||||
|
TagAlias.to_aliased(titles & tags)
|
||||||
end
|
end
|
||||||
|
|
||||||
def visible?
|
def visible?
|
||||||
|
|||||||
@@ -98,6 +98,14 @@ class RelatedTagQueryTest < ActiveSupport::TestCase
|
|||||||
query = RelatedTagQuery.new(query: "wiki")
|
query = RelatedTagQuery.new(query: "wiki")
|
||||||
assert_equal(%w[ccc bbb aaa], query.wiki_page_tags)
|
assert_equal(%w[ccc bbb aaa], query.wiki_page_tags)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
should "return aliased tags" do
|
||||||
|
create(:tag_alias, antecedent_name: "kitten", consequent_name: "cat", status: "active")
|
||||||
|
create(:wiki_page, title: "wiki", body: "[[kitten]]")
|
||||||
|
|
||||||
|
query = RelatedTagQuery.new(query: "wiki")
|
||||||
|
assert_equal(%w[cat], query.wiki_page_tags)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user