Commit 8e3d4da3 authored by Eric Davis's avatar Eric Davis

[#802] Show groups in the watchers partial and users autocomplete

parent 65e79956
...@@ -48,8 +48,14 @@ class AutoCompletesController < ApplicationController ...@@ -48,8 +48,14 @@ class AutoCompletesController < ApplicationController
end end
@removed_users ||= [] @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 render :layout => false
end end
......
...@@ -12,12 +12,12 @@ ...@@ -12,12 +12,12 @@
:object_id => watched}, :object_id => watched},
:method => :post, :method => :post,
:html => {:id => 'new-watcher-form', :style => 'display:none;'}) do |f| %> :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> <p><%= label_tag "user_search", l(:label_user_search) %><%= text_field_tag 'user_search', nil, :style => "width:98%;" %></p>
<%= observe_field(:user_search, <%= observe_field(:user_search,
:frequency => 0.5, :frequency => 0.5,
:update => :users, :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') :with => 'q')
%> %>
......
...@@ -92,6 +92,20 @@ class AutoCompletesControllerTest < ActionController::TestCase ...@@ -92,6 +92,20 @@ class AutoCompletesControllerTest < ActionController::TestCase
end end
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 context "restrict by removing group members" do
setup do setup do
@group = Group.first @group = Group.first
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment