Commit 889c79b54e4e51034f9cd5c8566d85c48e6466a6
1 parent
4ac525eb
Exists in
master
and in
29 other branches
Search by identifier on whitelist edition
Showing
2 changed files
with
10 additions
and
2 deletions
Show diff stats
app/controllers/admin/features_controller.rb
| ... | ... | @@ -53,7 +53,7 @@ class FeaturesController < AdminController |
| 53 | 53 | |
| 54 | 54 | def search_members |
| 55 | 55 | arg = params[:q].downcase |
| 56 | - result = environment.people.find(:all, :conditions => ['LOWER(name) LIKE ?', "%#{arg}%"]) | |
| 56 | + result = environment.people.find(:all, :conditions => ['LOWER(name) LIKE ? OR identifier LIKE ?', "%#{arg}%", "%#{arg}%"]) | |
| 57 | 57 | render :text => prepare_to_token_input(result).to_json |
| 58 | 58 | end |
| 59 | 59 | ... | ... |
test/functional/features_controller_test.rb
| ... | ... | @@ -146,7 +146,7 @@ class FeaturesControllerTest < ActionController::TestCase |
| 146 | 146 | assert_equal true, e.custom_community_fields['contact_person']['required'] |
| 147 | 147 | end |
| 148 | 148 | |
| 149 | - should 'search members' do | |
| 149 | + should 'search members by name' do | |
| 150 | 150 | uses_host 'anhetegua.net' |
| 151 | 151 | person = fast_create(Person, :environment_id => Environment.find(2).id) |
| 152 | 152 | xhr :get, :search_members, :q => person.name[0..2] |
| ... | ... | @@ -154,4 +154,12 @@ class FeaturesControllerTest < ActionController::TestCase |
| 154 | 154 | assert_includes json_response, {"id"=>person.id, "name"=>person.name} |
| 155 | 155 | end |
| 156 | 156 | |
| 157 | + should 'search members by identifier' do | |
| 158 | + uses_host 'anhetegua.net' | |
| 159 | + person = fast_create(Person, :name => 'Some Name', :identifier => 'person-identifier', :environment_id => Environment.find(2).id) | |
| 160 | + xhr :get, :search_members, :q => person.identifier | |
| 161 | + json_response = ActiveSupport::JSON.decode(@response.body) | |
| 162 | + assert_includes json_response, {"id"=>person.id, "name"=>person.name} | |
| 163 | + end | |
| 164 | + | |
| 157 | 165 | end | ... | ... |