Fixed: list of users for adding to a group may be empty if 100 first users have been added (#8029).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@5284 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
4e7835c68c
commit
b972b5a647
|
@ -132,7 +132,7 @@ class GroupsController < ApplicationController
|
||||||
|
|
||||||
def autocomplete_for_user
|
def autocomplete_for_user
|
||||||
@group = Group.find(params[:id])
|
@group = Group.find(params[:id])
|
||||||
@users = User.active.like(params[:q]).find(:all, :limit => 100) - @group.users
|
@users = User.active.not_in_group(@group).like(params[:q]).all(:limit => 100)
|
||||||
render :layout => false
|
render :layout => false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -80,6 +80,10 @@ class User < Principal
|
||||||
group_id = group.is_a?(Group) ? group.id : group.to_i
|
group_id = group.is_a?(Group) ? group.id : group.to_i
|
||||||
{ :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] }
|
{ :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] }
|
||||||
}
|
}
|
||||||
|
named_scope :not_in_group, lambda {|group|
|
||||||
|
group_id = group.is_a?(Group) ? group.id : group.to_i
|
||||||
|
{ :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] }
|
||||||
|
}
|
||||||
|
|
||||||
def before_create
|
def before_create
|
||||||
self.mail_notification = Setting.default_notification_option if self.mail_notification.blank?
|
self.mail_notification = Setting.default_notification_option if self.mail_notification.blank?
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="splitcontentright">
|
<div class="splitcontentright">
|
||||||
<% users = User.active.find(:all, :limit => 100) - @group.users %>
|
<% users = User.active.not_in_group(@group).all(:limit => 100) %>
|
||||||
<% if users.any? %>
|
<% if users.any? %>
|
||||||
<% remote_form_for(:group, @group, :url => {:controller => 'groups', :action => 'add_users', :id => @group}, :method => :post) do |f| %>
|
<% remote_form_for(:group, @group, :url => {:controller => 'groups', :action => 'add_users', :id => @group}, :method => :post) do |f| %>
|
||||||
<fieldset><legend><%=l(:label_user_new)%></legend>
|
<fieldset><legend><%=l(:label_user_new)%></legend>
|
||||||
|
|
|
@ -104,4 +104,13 @@ class GroupsControllerTest < ActionController::TestCase
|
||||||
post :destroy_membership, :id => 10, :membership_id => 6
|
post :destroy_membership, :id => 10, :membership_id => 6
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_autocomplete_for_user
|
||||||
|
get :autocomplete_for_user, :id => 10, :q => 'mis'
|
||||||
|
assert_response :success
|
||||||
|
users = assigns(:users)
|
||||||
|
assert_not_nil users
|
||||||
|
assert users.any?
|
||||||
|
assert !users.include?(Group.find(10).users.first)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue