diff --git a/app/controllers/public/invite_controller.rb b/app/controllers/public/invite_controller.rb index d0ddacc..e231f94 100644 --- a/app/controllers/public/invite_controller.rb +++ b/app/controllers/public/invite_controller.rb @@ -82,6 +82,8 @@ class InviteController < PublicController scope = profile.invite_friends_only ? user.friends : environment.people scope = scope.not_members_of(profile) if profile.organization? scope = scope.not_friends_of(profile) if profile.person? + scope = scope.distinct(false).group("profiles.id") + results = find_by_contents(:people, environment, scope, params['q'], {:page => 1}, {:joins => :user})[:results] render :text => prepare_to_token_input(results).to_json end diff --git a/plugins/pg_search/test/functional/invite_controller_test.rb b/plugins/pg_search/test/functional/invite_controller_test.rb new file mode 100644 index 0000000..b7f4fb8 --- /dev/null +++ b/plugins/pg_search/test/functional/invite_controller_test.rb @@ -0,0 +1,25 @@ +require "test_helper" + +class InviteControllerTest < ActionController::TestCase + + should 'list people available to invite' do + env = Environment.default + env.enable_plugin(PgSearchPlugin) + profile = create_user('profile').person + login_as(profile.identifier) + + community = fast_create(Community, :name => 'Testing community 1', :identifier => 'testcommunity1', :environment_id => env) + community.add_admin profile + + p1 = fast_create(Person, :identifier => 'someone') + p2 = fast_create(Person, :identifier => 'someother') + + assert_nothing_raised do + get :search, :profile => community.identifier, :q => 'some' + end + + assert_match p1.name, @response.body + assert_match p2.name, @response.body + end + +end -- libgit2 0.21.2