wiki pages: normalize unicode in other names.
This commit is contained in:
@@ -170,7 +170,7 @@ class WikiPage < ApplicationRecord
|
||||
end
|
||||
|
||||
def normalize_other_names
|
||||
normalized_other_names = other_names.to_s.gsub(/\u3000/, " ").scan(/\S+/)
|
||||
normalized_other_names = other_names.to_s.unicode_normalize(:nfkc).scan(/[^[:space:]]+/)
|
||||
self.other_names = normalized_other_names.uniq.join(" ")
|
||||
end
|
||||
|
||||
|
||||
@@ -61,6 +61,11 @@ class WikiPageTest < ActiveSupport::TestCase
|
||||
assert_equal("hot_potato", @wiki_page.title)
|
||||
end
|
||||
|
||||
should "normalize its other names" do
|
||||
@wiki_page.update(:other_names => "foo*bar baz baz 加賀(艦これ)")
|
||||
assert(%w[foo*bar baz 加賀(艦これ)], @wiki_page.other_names_array)
|
||||
end
|
||||
|
||||
should "search by title" do
|
||||
matches = WikiPage.titled("hot potato")
|
||||
assert_equal(1, matches.count)
|
||||
|
||||
Reference in New Issue
Block a user