mirror of
https://github.com/discourse/discourse.git
synced 2024-11-25 18:30:26 -06:00
FIX: Incorrect count when loading more groups.
This commit is contained in:
parent
193f8301a4
commit
502e114c60
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user