Commit 8470293887b42804d572dcffc5ee02af1a0d2ff6

Authored by Larissa Reis
1 parent 844304db

User can search friends for invitation using usp number

plugins/stoa/lib/stoa_plugin.rb
... ... @@ -124,4 +124,8 @@ class StoaPlugin < Noosfero::Plugin
124 124 {:field => :usp_id, :name => _('USP Number'), :model => 'person'}
125 125 end
126 126  
  127 + def search_friend_fields
  128 + [{:field => :usp_id, :name => _('USP Number')}]
  129 + end
  130 +
127 131 end
... ...
plugins/stoa/test/functional/invite_controller_test.rb
... ... @@ -48,5 +48,17 @@ class InviteControllerTest < ActionController::TestCase
48 48 assert_response 200
49 49 end
50 50  
  51 + should 'search friends profiles by usp_id' do
  52 + person1 = User.create!(:login => 'john', :email => 'john@example.com', :password => 'test', :password_confirmation => 'test', :person_data => {:usp_id => 12345678}).person
  53 + User.create!(:login => 'mary', :email => 'mary@example.com', :password => 'test', :password_confirmation => 'test', :person_data => {:usp_id => 11111111}).person
  54 + organization = fast_create(Organization)
  55 + organization.add_admin(person1)
  56 +
  57 + login_as(person1.identifier)
  58 + get :search_friend, :profile => organization.identifier, :q => '1234'
  59 +
  60 + assert_equal [{"name" => person1.name, "id" => person1.id}].to_json, @response.body
  61 + assert_response 200
  62 + end
51 63 end
52 64  
... ...