diff options
author | Bob Van Landuyt <bob@vanlanduyt.co> | 2017-10-02 13:54:12 +0300 |
---|---|---|
committer | Bob Van Landuyt <bob@vanlanduyt.co> | 2017-10-04 23:49:42 +0300 |
commit | 8a685ca8562a288f0a14f1b5864b97e90fe8c709 (patch) | |
tree | 1b67f355dda25bd172e9976f250873f4589a7856 /spec/controllers/groups_controller_spec.rb | |
parent | 9870453eee8a638025bc3e12649d5918eb524518 (diff) |
Fix bug with project pagination
When projects were listed after groups, the projects that would also
have been listed on the last page containing groups would be repeated.
Diffstat (limited to 'spec/controllers/groups_controller_spec.rb')
-rw-r--r-- | spec/controllers/groups_controller_spec.rb | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/spec/controllers/groups_controller_spec.rb b/spec/controllers/groups_controller_spec.rb index d33251f2641..00a6fa885bf 100644 --- a/spec/controllers/groups_controller_spec.rb +++ b/spec/controllers/groups_controller_spec.rb @@ -152,13 +152,15 @@ describe GroupsController do describe 'GET #show' do context 'pagination' do + let(:per_page) { 3 } + before do - allow(Kaminari.config).to receive(:default_per_page).and_return(2) + allow(Kaminari.config).to receive(:default_per_page).and_return(per_page) end context 'with only projects' do let!(:other_project) { create(:project, :public, namespace: group) } - let!(:first_page_projects) { create_list(:project, Kaminari.config.default_per_page, :public, namespace: group ) } + let!(:first_page_projects) { create_list(:project, per_page, :public, namespace: group ) } it 'has projects on the first page' do get :show, id: group.to_param, sort: 'id_desc' @@ -174,9 +176,9 @@ describe GroupsController do end context 'with subgroups and projects', :nested_groups do - let!(:first_page_subgroups) { create_list(:group, Kaminari.config.default_per_page, parent: group) } + let!(:first_page_subgroups) { create_list(:group, per_page, :public, parent: group) } let!(:other_subgroup) { create(:group, :public, parent: group) } - let!(:project) { create(:project, :public, namespace: group) } + let!(:next_page_projects) { create_list(:project, per_page, :public, namespace: group) } it 'contains all subgroups' do get :children, id: group.to_param, sort: 'id_asc', format: :json @@ -187,7 +189,7 @@ describe GroupsController do it 'contains the project and group on the second page' do get :children, id: group.to_param, sort: 'id_asc', page: 2, format: :json - expect(assigns(:children)).to contain_exactly(other_subgroup, project) + expect(assigns(:children)).to contain_exactly(other_subgroup, *next_page_projects.take(per_page - 1)) end end end |