Commit 038c04ea414fa21e63c4709259cf269c65d2793f
Exists in
fix_sign_up_form
Merge branch 'fix_invite_friend_to_community' into 'master'
avoid pg search plugin to broke invite members See merge request !999
Showing
2 changed files
with
24 additions
and
0 deletions
Show diff stats
app/controllers/public/invite_controller.rb
@@ -82,6 +82,8 @@ class InviteController < PublicController | @@ -82,6 +82,8 @@ class InviteController < PublicController | ||
82 | scope = profile.invite_friends_only ? user.friends : environment.people | 82 | scope = profile.invite_friends_only ? user.friends : environment.people |
83 | scope = scope.not_members_of(profile) if profile.organization? | 83 | scope = scope.not_members_of(profile) if profile.organization? |
84 | scope = scope.not_friends_of(profile) if profile.person? | 84 | scope = scope.not_friends_of(profile) if profile.person? |
85 | + scope = scope.distinct(false).group("profiles.id") | ||
86 | + | ||
85 | results = find_by_contents(:people, environment, scope, params['q'], {:page => 1}, {:joins => :user})[:results] | 87 | results = find_by_contents(:people, environment, scope, params['q'], {:page => 1}, {:joins => :user})[:results] |
86 | render :text => prepare_to_token_input(results).to_json | 88 | render :text => prepare_to_token_input(results).to_json |
87 | end | 89 | end |
plugins/pg_search/test/functional/invite_controller_test.rb
0 → 100644
@@ -0,0 +1,22 @@ | @@ -0,0 +1,22 @@ | ||
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 | + end | ||
21 | + | ||
22 | +end |