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: {