diff --git a/app/controllers/watcher_groups_controller.rb b/app/controllers/watcher_groups_controller.rb index 6cf3695..3c43578 100644 --- a/app/controllers/watcher_groups_controller.rb +++ b/app/controllers/watcher_groups_controller.rb @@ -66,7 +66,7 @@ def destroy end def autocomplete_for_group - @groups = Group.active.like(params[:q]).find(:all, :limit => 100) + @groups = Group.sorted.active.like(params[:q]).limit(100) if @watched @groups -= @watched.watcher_groups end diff --git a/lib/watcher_groups_issue_patch.rb b/lib/watcher_groups_issue_patch.rb index d9203ab..786354f 100644 --- a/lib/watcher_groups_issue_patch.rb +++ b/lib/watcher_groups_issue_patch.rb @@ -88,15 +88,15 @@ def notified_watchers_with_groups if respond_to?(:visible?) group_users.reject! {|user| !visible?(user)} end - notified += group_users + notified |= group_users end - notified += watcher_users.to_a + notified |= watcher_users.to_a notified.reject! {|user| user.mail.blank? || user.mail_notification == 'none'} if respond_to?(:visible?) notified.reject! {|user| !visible?(user)} end - notified.uniq + notified end def watched_by_with_groups?(user) @@ -108,10 +108,12 @@ def watched_by_with_groups?(user) def watcher_users_with_users users = watcher_users_without_users + old_object = users watcher_groups.each do |g| - users += g.users + users |= g.users end if self.id? - users.uniq + users.define_singleton_method(:reset) do old_object.reset end if old_object.class != users.class + users end end end