From 3efde2618d7c96476285dfe5e2413f270c0ac105 Mon Sep 17 00:00:00 2001 From: Guo Xiang Tan Date: Fri, 6 Oct 2017 10:35:40 +0800 Subject: [PATCH] UX: Do not display non-human users on group page. https://meta.discourse.org/t/members-of-groups-staff/71437 --- app/controllers/groups_controller.rb | 8 +++++--- spec/requests/groups_controller_spec.rb | 4 +++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/app/controllers/groups_controller.rb b/app/controllers/groups_controller.rb index 7691f99cab2..2785e69312c 100644 --- a/app/controllers/groups_controller.rb +++ b/app/controllers/groups_controller.rb @@ -125,15 +125,17 @@ class GroupsController < ApplicationController order = "#{params[:order]} #{dir} NULLS LAST" end - total = group.users.count - members = group.users + users = group.users.human_users + + total = users.count + members = users .order('NOT group_users.owner') .order(order) .order(username_lower: dir) .limit(limit) .offset(offset) - owners = group.users + owners = users .order(order) .order(username_lower: dir) .where('group_users.owner') diff --git a/spec/requests/groups_controller_spec.rb b/spec/requests/groups_controller_spec.rb index f808ed7578d..5e4f729a241 100644 --- a/spec/requests/groups_controller_spec.rb +++ b/spec/requests/groups_controller_spec.rb @@ -183,7 +183,9 @@ describe GroupsController do ) end - let(:group) { Fabricate(:group, users: [user1, user2, user3]) } + let(:bot) { Fabricate(:user, id: -999) } + + let(:group) { Fabricate(:group, users: [user1, user2, user3, bot]) } it "should allow members to be sorted by" do get "/groups/#{group.name}/members.json", params: {