diff --git a/app/models/user.rb b/app/models/user.rb index 1407748c..49f462f1 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -9,6 +9,10 @@ class User < ApplicationRecord :timeoutable ] + ransacker :username do + Arel.sql('unaccent(users.username)') + end + GENDERS = %w( female male diff --git a/spec/controllers/users_controller_spec.rb b/spec/controllers/users_controller_spec.rb index a9ce2263..a677d6d1 100644 --- a/spec/controllers/users_controller_spec.rb +++ b/spec/controllers/users_controller_spec.rb @@ -146,6 +146,15 @@ expect(assigns(:members)).to include(member) end + + it 'allows to search a member ignoring accents of user\'s username' do + user = Fabricate(:user, username: 'fôô', email: 'test@email.com') + member = Fabricate(:member, user: user, organization: test_organization) + + get :index, params: { q: { member_search_cont: "foo" } } + + expect(assigns(:members)).to include(member) + end end end