diff options
-rw-r--r-- | app/controllers/groups_controller.rb | 2 | ||||
-rw-r--r-- | spec/controllers/groups_controller_spec.rb | 18 |
2 files changed, 19 insertions, 1 deletions
diff --git a/app/controllers/groups_controller.rb b/app/controllers/groups_controller.rb index c967488fff4..4f0d1f88e58 100644 --- a/app/controllers/groups_controller.rb +++ b/app/controllers/groups_controller.rb @@ -46,7 +46,6 @@ class GroupsController < Groups::ApplicationController def show @children = GroupChildrenFinder.new(current_user, parent_group: @group, params: params).execute - @children = @children.page(params[:page]) respond_to do |format| @@ -71,6 +70,7 @@ class GroupsController < Groups::ApplicationController end @children = GroupChildrenFinder.new(current_user, parent_group: parent, params: params).execute + @children = @children.page(params[:page]) respond_to do |format| format.json do diff --git a/spec/controllers/groups_controller_spec.rb b/spec/controllers/groups_controller_spec.rb index c96a44d6186..9b4654dc3e4 100644 --- a/spec/controllers/groups_controller_spec.rb +++ b/spec/controllers/groups_controller_spec.rb @@ -466,6 +466,24 @@ describe GroupsController do end end end + + context 'pagination' do + let!(:other_subgroup) { create(:group, :public, parent: group) } + let!(:project) { create(:project, :public, namespace: group) } + let!(:first_page_subgroups) { create_list(:group, Kaminari.config.default_per_page, parent: group) } + + it 'contains all subgroups' do + get :children, id: group.to_param, sort: 'id', format: :json + + expect(assigns(:children)).to contain_exactly(*first_page_subgroups) + end + + it 'contains the project and group on the second page' do + get :children, id: group.to_param, sort: 'id', page: 2, format: :json + + expect(assigns(:children)).to contain_exactly(other_subgroup, project) + end + end end context 'for a POST request' do |