Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBob Van Landuyt <bob@vanlanduyt.co>2017-10-10 15:11:55 +0300
committerBob Van Landuyt <bob@vanlanduyt.co>2017-10-10 17:54:28 +0300
commitaee5691db3ec411c242e050aaa11ebb44f07f164 (patch)
tree1bacabb4632b3d90701729d32cbaf41ddeb51c14 /spec/controllers/groups_controller_spec.rb
parent3fe7f31ac047e1b9ba3ae53cea17012ce2f7f3e7 (diff)
Don't load unneeded elements in GroupsController#show
Diffstat (limited to 'spec/controllers/groups_controller_spec.rb')
-rw-r--r--spec/controllers/groups_controller_spec.rb89
1 files changed, 44 insertions, 45 deletions
diff --git a/spec/controllers/groups_controller_spec.rb b/spec/controllers/groups_controller_spec.rb
index 8582f31f059..f914fd6f20a 100644
--- a/spec/controllers/groups_controller_spec.rb
+++ b/spec/controllers/groups_controller_spec.rb
@@ -150,51 +150,6 @@ describe GroupsController do
end
end
- describe 'GET #show' do
- context 'pagination' do
- let(:per_page) { 3 }
-
- before do
- 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, per_page, :public, namespace: group ) }
-
- it 'has projects on the first page' do
- get :show, id: group.to_param, sort: 'id_desc'
-
- expect(assigns(:children)).to contain_exactly(*first_page_projects)
- end
-
- it 'has projects on the second page' do
- get :show, id: group.to_param, sort: 'id_desc', page: 2
-
- expect(assigns(:children)).to contain_exactly(other_project)
- end
- end
-
- context 'with subgroups and projects', :nested_groups do
- let!(:first_page_subgroups) { create_list(:group, per_page, :public, parent: group) }
- let!(:other_subgroup) { create(:group, :public, parent: 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
-
- 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_asc', page: 2, format: :json
-
- expect(assigns(:children)).to contain_exactly(other_subgroup, *next_page_projects.take(per_page - 1))
- end
- end
- end
- end
-
describe 'GET #children' do
context 'for projects' do
let!(:public_project) { create(:project, :public, namespace: group) }
@@ -420,6 +375,50 @@ describe GroupsController do
end
end
end
+
+ context 'pagination' do
+ let(:per_page) { 3 }
+
+ before do
+ 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, per_page, :public, namespace: group ) }
+
+ it 'has projects on the first page' do
+ get :children, id: group.to_param, sort: 'id_desc', format: :json
+
+ expect(assigns(:children)).to contain_exactly(*first_page_projects)
+ end
+
+ it 'has projects on the second page' do
+ get :children, id: group.to_param, sort: 'id_desc', page: 2, format: :json
+
+ expect(assigns(:children)).to contain_exactly(other_project)
+ end
+ end
+
+ context 'with subgroups and projects', :nested_groups do
+ let!(:first_page_subgroups) { create_list(:group, per_page, :public, parent: group) }
+ let!(:other_subgroup) { create(:group, :public, parent: 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
+
+ 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_asc', page: 2, format: :json
+
+ expect(assigns(:children)).to contain_exactly(other_subgroup, *next_page_projects.take(per_page - 1))
+ end
+ end
+ end
+
end
describe 'GET #issues' do