diff --git a/app/controllers/admin/features_controller.rb b/app/controllers/admin/features_controller.rb index b71dafe..4bbe006 100644 --- a/app/controllers/admin/features_controller.rb +++ b/app/controllers/admin/features_controller.rb @@ -53,7 +53,7 @@ class FeaturesController < AdminController def search_members arg = params[:q].downcase - result = environment.people.find(:all, :conditions => ['LOWER(name) LIKE ?', "%#{arg}%"]) + result = environment.people.find(:all, :conditions => ['LOWER(name) LIKE ? OR identifier LIKE ?', "%#{arg}%", "%#{arg}%"]) render :text => prepare_to_token_input(result).to_json end diff --git a/test/functional/features_controller_test.rb b/test/functional/features_controller_test.rb index ab78a9d..47d9276 100644 --- a/test/functional/features_controller_test.rb +++ b/test/functional/features_controller_test.rb @@ -146,7 +146,7 @@ class FeaturesControllerTest < ActionController::TestCase assert_equal true, e.custom_community_fields['contact_person']['required'] end - should 'search members' do + should 'search members by name' do uses_host 'anhetegua.net' person = fast_create(Person, :environment_id => Environment.find(2).id) xhr :get, :search_members, :q => person.name[0..2] @@ -154,4 +154,12 @@ class FeaturesControllerTest < ActionController::TestCase assert_includes json_response, {"id"=>person.id, "name"=>person.name} end + should 'search members by identifier' do + uses_host 'anhetegua.net' + person = fast_create(Person, :name => 'Some Name', :identifier => 'person-identifier', :environment_id => Environment.find(2).id) + xhr :get, :search_members, :q => person.identifier + json_response = ActiveSupport::JSON.decode(@response.body) + assert_includes json_response, {"id"=>person.id, "name"=>person.name} + end + end -- libgit2 0.21.2