Commit 3b1b0dda authored by Tetiana Chupryna's avatar Tetiana Chupryna

Merge branch '348509-add-method-to-control-user-search-minium-char-limit' into 'master'

Add toggle method to control use_minimum_char_limit

See merge request gitlab-org/gitlab!76835
parents b098b5bc 681bd8b8
...@@ -708,13 +708,19 @@ class User < ApplicationRecord ...@@ -708,13 +708,19 @@ class User < ApplicationRecord
.take(1) # at most 1 record as there is a unique constraint .take(1) # at most 1 record as there is a unique constraint
where( where(
fuzzy_arel_match(:name, query) fuzzy_arel_match(:name, query, use_minimum_char_limit: user_search_minimum_char_limit)
.or(fuzzy_arel_match(:username, query)) .or(fuzzy_arel_match(:username, query, use_minimum_char_limit: user_search_minimum_char_limit))
.or(arel_table[:email].eq(query)) .or(arel_table[:email].eq(query))
.or(arel_table[:id].eq(matched_by_email_user_id)) .or(arel_table[:id].eq(matched_by_email_user_id))
) )
end end
# This method is overridden in JiHu.
# https://gitlab.com/gitlab-org/gitlab/-/issues/348509
def user_search_minimum_char_limit
true
end
def by_login(login) def by_login(login)
return unless login return unless login
......
...@@ -2592,6 +2592,12 @@ RSpec.describe User do ...@@ -2592,6 +2592,12 @@ RSpec.describe User do
end end
end end
describe '.user_search_minimum_char_limit' do
it 'returns true' do
expect(described_class.user_search_minimum_char_limit).to be(true)
end
end
describe '.find_by_ssh_key_id' do describe '.find_by_ssh_key_id' do
let_it_be(:user) { create(:user) } let_it_be(:user) { create(:user) }
let_it_be(:key) { create(:key, user: user) } let_it_be(:key) { create(:key, user: user) }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment