From 9f46488805e86b1bc341ea1620b866016c2ce5ed Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Wed, 20 May 2020 14:34:42 +0000 Subject: Add latest changes from gitlab-org/gitlab@13-0-stable-ee --- .../controllers/groups/clusters_controller_spec.rb | 25 +++++++++++++-- .../groups/group_links_controller_spec.rb | 36 ---------------------- .../registry/repositories_controller_spec.rb | 30 ++++++++++++++++-- .../settings/integrations_controller_spec.rb | 4 +-- .../groups/settings/repository_controller_spec.rb | 4 +-- 5 files changed, 54 insertions(+), 45 deletions(-) (limited to 'spec/controllers/groups') diff --git a/spec/controllers/groups/clusters_controller_spec.rb b/spec/controllers/groups/clusters_controller_spec.rb index 28a174560dd..1f2f6bd811b 100644 --- a/spec/controllers/groups/clusters_controller_spec.rb +++ b/spec/controllers/groups/clusters_controller_spec.rb @@ -32,7 +32,7 @@ describe Groups::ClustersController do create(:cluster, :disabled, :provided_by_gcp, :production_environment, cluster_type: :group_type, groups: [group]) end - it 'lists available clusters' do + it 'lists available clusters and renders html' do go expect(response).to have_gitlab_http_status(:ok) @@ -40,20 +40,39 @@ describe Groups::ClustersController do expect(assigns(:clusters)).to match_array([enabled_cluster, disabled_cluster]) end + it 'lists available clusters with json serializer' do + go(format: :json) + + expect(response).to have_gitlab_http_status(:ok) + expect(response).to match_response_schema('cluster_list') + end + context 'when page is specified' do let(:last_page) { group.clusters.page.total_pages } + let(:total_count) { group.clusters.page.total_count } before do - allow(Clusters::Cluster).to receive(:paginates_per).and_return(1) - create_list(:cluster, 2, :provided_by_gcp, :production_environment, cluster_type: :group_type, groups: [group]) + create_list(:cluster, 30, :provided_by_gcp, :production_environment, cluster_type: :group_type, groups: [group]) end it 'redirects to the page' do + expect(last_page).to be > 1 + go(page: last_page) expect(response).to have_gitlab_http_status(:ok) expect(assigns(:clusters).current_page).to eq(last_page) end + + it 'displays cluster list for associated page' do + expect(last_page).to be > 1 + + go(page: last_page, format: :json) + + expect(response).to have_gitlab_http_status(:ok) + expect(response.headers['X-Page'].to_i).to eq(last_page) + expect(response.headers['X-Total'].to_i).to eq(total_count) + end end end diff --git a/spec/controllers/groups/group_links_controller_spec.rb b/spec/controllers/groups/group_links_controller_spec.rb index 21169188386..ca430414d17 100644 --- a/spec/controllers/groups/group_links_controller_spec.rb +++ b/spec/controllers/groups/group_links_controller_spec.rb @@ -99,18 +99,6 @@ describe Groups::GroupLinksController do expect(flash[:alert]).to eq('error') end end - - context 'when feature flag is disabled' do - before do - stub_feature_flags(share_group_with_group: false) - end - - it 'renders 404' do - subject - - expect(response).to have_gitlab_http_status(:not_found) - end - end end context 'when user does not have access to the group' do @@ -184,18 +172,6 @@ describe Groups::GroupLinksController do expect(response).to have_gitlab_http_status(:not_found) end end - - context 'when feature flag is disabled' do - before do - stub_feature_flags(share_group_with_group: false) - end - - it 'renders 404' do - subject - - expect(response).to have_gitlab_http_status(:not_found) - end - end end describe '#destroy' do @@ -231,17 +207,5 @@ describe Groups::GroupLinksController do expect(response).to have_gitlab_http_status(:not_found) end end - - context 'when feature flag is disabled' do - before do - stub_feature_flags(share_group_with_group: false) - end - - it 'renders 404' do - subject - - expect(response).to have_gitlab_http_status(:not_found) - end - end end end diff --git a/spec/controllers/groups/registry/repositories_controller_spec.rb b/spec/controllers/groups/registry/repositories_controller_spec.rb index a84664c6c04..7b78aeadbd8 100644 --- a/spec/controllers/groups/registry/repositories_controller_spec.rb +++ b/spec/controllers/groups/registry/repositories_controller_spec.rb @@ -6,12 +6,13 @@ describe Groups::Registry::RepositoriesController do let_it_be(:user) { create(:user) } let_it_be(:guest) { create(:user) } let_it_be(:group, reload: true) { create(:group) } + let(:additional_parameters) { {} } subject do - get :index, params: { + get :index, params: additional_parameters.merge({ group_id: group, format: format - } + }) end before do @@ -36,6 +37,25 @@ describe Groups::Registry::RepositoriesController do end end + shared_examples 'with name parameter' do + let_it_be(:project) { create(:project, group: test_group) } + let_it_be(:repo) { create(:container_repository, project: project, name: 'my_searched_image') } + let_it_be(:another_repo) { create(:container_repository, project: project, name: 'bar') } + + let(:additional_parameters) { { name: 'my_searched_image' } } + + it 'returns the searched repo' do + subject + + expect(response).to have_gitlab_http_status(:ok) + expect(json_response.length).to eq 1 + expect(json_response.first).to include( + 'id' => repo.id, + 'name' => repo.name + ) + end + end + shared_examples 'renders correctly' do context 'when user has access to registry' do let_it_be(:test_group) { group } @@ -64,6 +84,8 @@ describe Groups::Registry::RepositoriesController do it_behaves_like 'renders a list of repositories' + it_behaves_like 'with name parameter' + it_behaves_like 'a gitlab tracking event', described_class.name, 'list_repositories' context 'with project in subgroup' do @@ -71,6 +93,8 @@ describe Groups::Registry::RepositoriesController do it_behaves_like 'renders a list of repositories' + it_behaves_like 'with name parameter' + context 'with project in subgroup and group' do let_it_be(:repo_in_test_group) { create_project_with_repo(test_group) } let_it_be(:repo_in_group) { create_project_with_repo(group) } @@ -81,6 +105,8 @@ describe Groups::Registry::RepositoriesController do expect(json_response).to be_kind_of(Array) expect(json_response.length).to eq 2 end + + it_behaves_like 'with name parameter' end end end diff --git a/spec/controllers/groups/settings/integrations_controller_spec.rb b/spec/controllers/groups/settings/integrations_controller_spec.rb index 76cd74de183..29c93c621bd 100644 --- a/spec/controllers/groups/settings/integrations_controller_spec.rb +++ b/spec/controllers/groups/settings/integrations_controller_spec.rb @@ -27,7 +27,7 @@ describe Groups::Settings::IntegrationsController do context 'when group_level_integrations not enabled' do it 'returns not_found' do - stub_feature_flags(group_level_integrations: { enabled: false, thing: group }) + stub_feature_flags(group_level_integrations: false) get :index, params: { group_id: group } @@ -60,7 +60,7 @@ describe Groups::Settings::IntegrationsController do context 'when group_level_integrations not enabled' do it 'returns not_found' do - stub_feature_flags(group_level_integrations: { enabled: false, thing: group }) + stub_feature_flags(group_level_integrations: false) get :edit, params: { group_id: group, id: Service.available_services_names.sample } diff --git a/spec/controllers/groups/settings/repository_controller_spec.rb b/spec/controllers/groups/settings/repository_controller_spec.rb index 20070fb17a0..9523d404538 100644 --- a/spec/controllers/groups/settings/repository_controller_spec.rb +++ b/spec/controllers/groups/settings/repository_controller_spec.rb @@ -15,7 +15,7 @@ describe Groups::Settings::RepositoryController do describe 'POST create_deploy_token' do context 'when ajax_new_deploy_token feature flag is disabled for the project' do before do - stub_feature_flags(ajax_new_deploy_token: { enabled: false, thing: group }) + stub_feature_flags(ajax_new_deploy_token: false) entity.add_owner(user) end @@ -56,7 +56,7 @@ describe Groups::Settings::RepositoryController do 'id' => be_a(Integer), 'name' => deploy_token_params[:name], 'username' => deploy_token_params[:username], - 'expires_at' => Time.parse(deploy_token_params[:expires_at]), + 'expires_at' => Time.zone.parse(deploy_token_params[:expires_at]), 'token' => be_a(String), 'scopes' => deploy_token_params.inject([]) do |scopes, kv| key, value = kv -- cgit v1.2.1