[#802] Show groups in the watchers partial and users autocomplete
This commit is contained in:
parent
65e7995682
commit
8e3d4da376
|
@ -48,8 +48,14 @@ class AutoCompletesController < ApplicationController
|
|||
end
|
||||
|
||||
@removed_users ||= []
|
||||
|
||||
if params[:include_groups]
|
||||
user_finder = Principal
|
||||
else
|
||||
user_finder = User
|
||||
end
|
||||
|
||||
@users = User.active.like(params[:q]).find(:all, :limit => 100) - @removed_users
|
||||
@users = user_finder.active.like(params[:q]).find(:all, :limit => 100) - @removed_users
|
||||
render :layout => false
|
||||
end
|
||||
|
||||
|
|
|
@ -12,12 +12,12 @@
|
|||
:object_id => watched},
|
||||
:method => :post,
|
||||
:html => {:id => 'new-watcher-form', :style => 'display:none;'}) do |f| %>
|
||||
<% users = User.active.find(:all, :limit => 25) - watched.watcher_users %>
|
||||
<% users = Principal.active.find(:all, :limit => 25) - watched.watcher_users %>
|
||||
<p><%= label_tag "user_search", l(:label_user_search) %><%= text_field_tag 'user_search', nil, :style => "width:98%;" %></p>
|
||||
<%= observe_field(:user_search,
|
||||
:frequency => 0.5,
|
||||
:update => :users,
|
||||
:url => auto_complete_users_path(:remove_watchers => watched.id, :klass => watched.class),
|
||||
:url => auto_complete_users_path(:remove_watchers => watched.id, :klass => watched.class, :include_groups => true),
|
||||
:with => 'q')
|
||||
%>
|
||||
|
||||
|
|
|
@ -92,6 +92,20 @@ class AutoCompletesControllerTest < ActionController::TestCase
|
|||
end
|
||||
end
|
||||
|
||||
context "including groups" do
|
||||
setup do
|
||||
@group = Group.generate(:lastname => 'Complete Group').reload
|
||||
get :users, :q => 'complete', :include_groups => true
|
||||
end
|
||||
|
||||
should_respond_with :success
|
||||
|
||||
should "include matching groups" do
|
||||
assert_select "input[type=checkbox][value=?]", @group.id
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
context "restrict by removing group members" do
|
||||
setup do
|
||||
@group = Group.first
|
||||
|
|
Loading…
Reference in New Issue