FIX: Infinite loading more on groups page.

This commit is contained in:
Guo Xiang Tan 2018-03-21 09:25:42 +08:00
parent 2baff71518
commit 9f216ac182
2 changed files with 4 additions and 3 deletions

View File

@ -59,9 +59,6 @@ class GroupsController < ApplicationController
type_filters.delete(:automatic)
end
count = groups.count
groups = groups.offset(page * page_size).limit(page_size)
if Group.preloaded_custom_field_names.present?
Group.preload_custom_fields(groups, Group.preloaded_custom_field_names)
end
@ -76,6 +73,9 @@ class GroupsController < ApplicationController
owner_group_ids = group_users.where(owner: true).pluck(:group_id)
end
count = groups.count
groups = groups.offset(page * page_size).limit(page_size)
render_json_dump(
groups: serialize_data(groups,
BasicGroupSerializer,

View File

@ -128,6 +128,7 @@ describe GroupsController do
response_body = JSON.parse(response.body)
group_ids = response_body["groups"].map { |g| g["id"] }
expect(response_body["total_rows_groups"]).to eq(expected_group_ids.count)
expect(group_ids).to contain_exactly(*expected_group_ids)
end