Commit 64622c39afd61edd3f53050b055011428c97021f
Committed by
Antonio Terceiro
1 parent
d73c3900
Exists in
master
and in
28 other branches
ActionItem1127: search by prefix instead of full word
Showing
2 changed files
with
15 additions
and
1 deletions
Show diff stats
app/controllers/my_profile/profile_members_controller.rb
@@ -76,7 +76,7 @@ class ProfileMembersController < MyProfileController | @@ -76,7 +76,7 @@ class ProfileMembersController < MyProfileController | ||
76 | end | 76 | end |
77 | 77 | ||
78 | def find_users | 78 | def find_users |
79 | - @users_found = Person.find_by_contents(params[:query]) | 79 | + @users_found = Person.find_by_contents(params[:query] + '*') |
80 | render :layout => false | 80 | render :layout => false |
81 | end | 81 | end |
82 | 82 |
test/functional/profile_members_controller_test.rb
@@ -239,4 +239,18 @@ class ProfileMembersControllerTest < Test::Unit::TestCase | @@ -239,4 +239,18 @@ class ProfileMembersControllerTest < Test::Unit::TestCase | ||
239 | assert_tag :tag => 'tr', :attributes => {:id => 'tr-test_user', :style => 'display:none'} | 239 | assert_tag :tag => 'tr', :attributes => {:id => 'tr-test_user', :style => 'display:none'} |
240 | end | 240 | end |
241 | 241 | ||
242 | + should 'return users with <query> as a prefix' do | ||
243 | + daniel = create_user('daniel').person | ||
244 | + daniela = create_user('daniela').person | ||
245 | + | ||
246 | + ent = Enterprise.create!(:name => 'Test Ent', :identifier => 'test_ent') | ||
247 | + p = create_user_with_permission('test_user', 'manage_memberships', ent) | ||
248 | + login_as :test_user | ||
249 | + | ||
250 | + get :find_users, :profile => ent.identifier, :query => 'daniel' | ||
251 | + | ||
252 | + assert_includes assigns(:users_found), daniel | ||
253 | + assert_includes assigns(:users_found), daniela | ||
254 | + end | ||
255 | + | ||
242 | end | 256 | end |