dmails: fix case sensitivity bug in dmail title search.

This commit is contained in:
evazion
2017-05-21 13:52:56 -05:00
parent a4220854a3
commit 3f760069b3
2 changed files with 4 additions and 1 deletions

View File

@@ -104,7 +104,7 @@ class Dmail < ActiveRecord::Base
def title_matches(query)
query = "*#{query}*" unless query =~ /\*/
where("lower(dmails.title) LIKE ?", query.to_escaped_for_sql_like)
where("lower(dmails.title) LIKE ?", query.mb_chars.downcase.to_escaped_for_sql_like)
end
def search_message(query)

View File

@@ -78,6 +78,9 @@ class DmailTest < ActiveSupport::TestCase
matches = Dmail.search(title_matches: "x")
assert_equal([dmail.id], matches.map(&:id))
matches = Dmail.search(title_matches: "X")
assert_equal([dmail.id], matches.map(&:id))
matches = Dmail.search(message_matches: "xxx")
assert_equal([dmail.id], matches.map(&:id))