Commit 36202783023ae443695b900653f4d1460a09203b
1 parent
02903b02
Exists in
fix_sign_up_form
avoid pg search plugin to broke invite members
Showing
2 changed files
with
27 additions
and
0 deletions
Show diff stats
app/controllers/public/invite_controller.rb
... | ... | @@ -82,6 +82,8 @@ class InviteController < PublicController |
82 | 82 | scope = profile.invite_friends_only ? user.friends : environment.people |
83 | 83 | scope = scope.not_members_of(profile) if profile.organization? |
84 | 84 | scope = scope.not_friends_of(profile) if profile.person? |
85 | + scope = scope.distinct(false).group("profiles.id") | |
86 | + | |
85 | 87 | results = find_by_contents(:people, environment, scope, params['q'], {:page => 1}, {:joins => :user})[:results] |
86 | 88 | render :text => prepare_to_token_input(results).to_json |
87 | 89 | end | ... | ... |
plugins/pg_search/test/functional/invite_controller_test.rb
0 → 100644
... | ... | @@ -0,0 +1,25 @@ |
1 | +require "test_helper" | |
2 | + | |
3 | +class InviteControllerTest < ActionController::TestCase | |
4 | + | |
5 | + should 'list people available to invite' do | |
6 | + env = Environment.default | |
7 | + env.enable_plugin(PgSearchPlugin) | |
8 | + profile = create_user('profile').person | |
9 | + login_as(profile.identifier) | |
10 | + | |
11 | + community = fast_create(Community, :name => 'Testing community 1', :identifier => 'testcommunity1', :environment_id => env) | |
12 | + community.add_admin profile | |
13 | + | |
14 | + p1 = fast_create(Person, :identifier => 'someone') | |
15 | + p2 = fast_create(Person, :identifier => 'someother') | |
16 | + | |
17 | + assert_nothing_raised do | |
18 | + get :search, :profile => community.identifier, :q => 'some' | |
19 | + end | |
20 | + | |
21 | + assert_match p1.name, @response.body | |
22 | + assert_match p2.name, @response.body | |
23 | + end | |
24 | + | |
25 | +end | ... | ... |