##// END OF EJS Templates
Fixed: list of users for adding to a group may be empty if 100 first users have been added (#8029)....
Jean-Philippe Lang -
r5164:b972b5a647ca
parent child
Show More
@@ -132,7 +132,7 class GroupsController < ApplicationController
132 132
133 133 def autocomplete_for_user
134 134 @group = Group.find(params[:id])
135 @users = User.active.like(params[:q]).find(:all, :limit => 100) - @group.users
135 @users = User.active.not_in_group(@group).like(params[:q]).all(:limit => 100)
136 136 render :layout => false
137 137 end
138 138
@@ -80,6 +80,10 class User < Principal
80 80 group_id = group.is_a?(Group) ? group.id : group.to_i
81 81 { :conditions => ["#{User.table_name}.id IN (SELECT gu.user_id FROM #{table_name_prefix}groups_users#{table_name_suffix} gu WHERE gu.group_id = ?)", group_id] }
82 82 }
83 named_scope :not_in_group, lambda {|group|
84 group_id = group.is_a?(Group) ? group.id : group.to_i
85 { :conditions => ["#{User.table_name}.id NOT IN (SELECT gu.user_id FROM #{table_name_prefix}groups_users#{table_name_suffix} gu WHERE gu.group_id = ?)", group_id] }
86 }
83 87
84 88 def before_create
85 89 self.mail_notification = Setting.default_notification_option if self.mail_notification.blank?
@@ -24,7 +24,7
24 24 </div>
25 25
26 26 <div class="splitcontentright">
27 <% users = User.active.find(:all, :limit => 100) - @group.users %>
27 <% users = User.active.not_in_group(@group).all(:limit => 100) %>
28 28 <% if users.any? %>
29 29 <% remote_form_for(:group, @group, :url => {:controller => 'groups', :action => 'add_users', :id => @group}, :method => :post) do |f| %>
30 30 <fieldset><legend><%=l(:label_user_new)%></legend>
@@ -104,4 +104,13 class GroupsControllerTest < ActionController::TestCase
104 104 post :destroy_membership, :id => 10, :membership_id => 6
105 105 end
106 106 end
107
108 def test_autocomplete_for_user
109 get :autocomplete_for_user, :id => 10, :q => 'mis'
110 assert_response :success
111 users = assigns(:users)
112 assert_not_nil users
113 assert users.any?
114 assert !users.include?(Group.find(10).users.first)
115 end
107 116 end
General Comments 0
You need to be logged in to leave comments. Login now