Commit 889c79b54e4e51034f9cd5c8566d85c48e6466a6

Authored by Victor Costa
1 parent 4ac525eb

Search by identifier on whitelist edition

app/controllers/admin/features_controller.rb
@@ -53,7 +53,7 @@ class FeaturesController < AdminController @@ -53,7 +53,7 @@ class FeaturesController < AdminController
53 53
54 def search_members 54 def search_members
55 arg = params[:q].downcase 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 render :text => prepare_to_token_input(result).to_json 57 render :text => prepare_to_token_input(result).to_json
58 end 58 end
59 59
test/functional/features_controller_test.rb
@@ -146,7 +146,7 @@ class FeaturesControllerTest < ActionController::TestCase @@ -146,7 +146,7 @@ class FeaturesControllerTest < ActionController::TestCase
146 assert_equal true, e.custom_community_fields['contact_person']['required'] 146 assert_equal true, e.custom_community_fields['contact_person']['required']
147 end 147 end
148 148
149 - should 'search members' do 149 + should 'search members by name' do
150 uses_host 'anhetegua.net' 150 uses_host 'anhetegua.net'
151 person = fast_create(Person, :environment_id => Environment.find(2).id) 151 person = fast_create(Person, :environment_id => Environment.find(2).id)
152 xhr :get, :search_members, :q => person.name[0..2] 152 xhr :get, :search_members, :q => person.name[0..2]
@@ -154,4 +154,12 @@ class FeaturesControllerTest < ActionController::TestCase @@ -154,4 +154,12 @@ class FeaturesControllerTest < ActionController::TestCase
154 assert_includes json_response, {"id"=>person.id, "name"=>person.name} 154 assert_includes json_response, {"id"=>person.id, "name"=>person.name}
155 end 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 end 165 end