Skip to content

Commit

Permalink
member can be searched by username ignoring accents (#710)
Browse files Browse the repository at this point in the history
  • Loading branch information
nflorentin authored Nov 20, 2023
1 parent 2b383af commit 8332160
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
4 changes: 4 additions & 0 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ class User < ApplicationRecord
:timeoutable
]

ransacker :username do
Arel.sql('unaccent(users.username)')
end

GENDERS = %w(
female
male
Expand Down
9 changes: 9 additions & 0 deletions spec/controllers/users_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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: '[email protected]')
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

Expand Down

0 comments on commit 8332160

Please sign in to comment.