diff --git a/app/controllers/groups_controller.rb b/app/controllers/groups_controller.rb index 67b3de9938b..3f339f0d317 100644 --- a/app/controllers/groups_controller.rb +++ b/app/controllers/groups_controller.rb @@ -20,11 +20,12 @@ class GroupsController < ApplicationController groups = groups.where(automatic: false) end + count = groups.count groups = groups.offset(page * page_size).limit(page_size) render json: { groups: serialize_data(groups, BasicGroupSerializer), - total_rows_groups: Group.count, + total_rows_groups: count, load_more_groups: groups_path(page: page + 1) } end diff --git a/spec/integration/groups_spec.rb b/spec/integration/groups_spec.rb index 348f69f90e9..bedeb75e0ac 100644 --- a/spec/integration/groups_spec.rb +++ b/spec/integration/groups_spec.rb @@ -26,6 +26,7 @@ describe "Groups" do expect(group_ids).to include(other_group.id) expect(group_ids).to_not include(group.id) expect(response_body["load_more_groups"]).to eq("/groups?page=1") + expect(response_body["total_rows_groups"]).to eq(1) end context 'viewing as an admin' do @@ -42,6 +43,7 @@ describe "Groups" do expect(group_ids).to include(group.id, other_group.id) expect(response_body["load_more_groups"]).to eq("/groups?page=1") + expect(response_body["total_rows_groups"]).to eq(10) end end end