autocomplete: fix case sensitivity (#3854).

ref: https://github.com/r888888888/danbooru/issues/3854#issuecomment-417366253:
This commit is contained in:
evazion
2018-08-30 17:37:07 -05:00
parent 7f85dd27f9
commit a68d12bd45
2 changed files with 9 additions and 0 deletions

View File

@@ -10,6 +10,8 @@ module TagAutocomplete
end
def search(query)
query = Tag.normalize_name(query)
candidates = count_sort(
query,
search_prefix(query, 3) +

View File

@@ -3,6 +3,13 @@ require 'test_helper'
class TagAutocompleteTest < ActiveSupport::TestCase
subject { TagAutocomplete }
context "#search" do
should "be case insensitive" do
create(:tag, name: "abcdef", post_count: 1)
assert_equal(["abcdef"], subject.search("A").map(&:name))
end
end
context "#search_exact" do
setup do
@tags = [