diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-03-18 23:02:30 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-03-18 23:02:30 +0300 |
commit | 41fe97390ceddf945f3d967b8fdb3de4c66b7dea (patch) | |
tree | 9c8d89a8624828992f06d892cd2f43818ff5dcc8 /spec/requests/groups | |
parent | 0804d2dc31052fb45a1efecedc8e06ce9bc32862 (diff) |
Add latest changes from gitlab-org/gitlab@14-9-stable-eev14.9.0-rc42
Diffstat (limited to 'spec/requests/groups')
4 files changed, 121 insertions, 0 deletions
diff --git a/spec/requests/groups/crm/contacts_controller_spec.rb b/spec/requests/groups/crm/contacts_controller_spec.rb index 5d126c6ead5..4d8ca0fcd60 100644 --- a/spec/requests/groups/crm/contacts_controller_spec.rb +++ b/spec/requests/groups/crm/contacts_controller_spec.rb @@ -49,6 +49,12 @@ RSpec.describe Groups::Crm::ContactsController do it_behaves_like 'response with 404 status' end + + context 'when subgroup' do + let(:group) { create(:group, :private, :crm_enabled, parent: create(:group)) } + + it_behaves_like 'response with 404 status' + end end context 'with unauthorized user' do diff --git a/spec/requests/groups/crm/organizations_controller_spec.rb b/spec/requests/groups/crm/organizations_controller_spec.rb index f38300c3c5b..37ffac71772 100644 --- a/spec/requests/groups/crm/organizations_controller_spec.rb +++ b/spec/requests/groups/crm/organizations_controller_spec.rb @@ -49,6 +49,12 @@ RSpec.describe Groups::Crm::OrganizationsController do it_behaves_like 'response with 404 status' end + + context 'when subgroup' do + let(:group) { create(:group, :private, :crm_enabled, parent: create(:group)) } + + it_behaves_like 'response with 404 status' + end end context 'with unauthorized user' do diff --git a/spec/requests/groups/deploy_tokens_controller_spec.rb b/spec/requests/groups/deploy_tokens_controller_spec.rb new file mode 100644 index 00000000000..b3dce9b9cf1 --- /dev/null +++ b/spec/requests/groups/deploy_tokens_controller_spec.rb @@ -0,0 +1,40 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Groups::DeployTokensController do + let_it_be(:group) { create(:group) } + let_it_be(:user) { create(:user) } + let_it_be(:deploy_token) { create(:deploy_token, :group, groups: [group]) } + let_it_be(:params) do + { id: deploy_token.id, group_id: group } + end + + before do + group.add_owner(user) + + sign_in(user) + end + + describe 'PUT /groups/:group_path_with_namespace/-/deploy_tokens/:id/revoke' do + subject(:put_revoke) do + put "/groups/#{group.full_path}/-/deploy_tokens/#{deploy_token.id}/revoke", params: params + end + + it 'invokes the Groups::DeployTokens::RevokeService' do + expect(deploy_token.revoked).to eq(false) + expect(Groups::DeployTokens::RevokeService).to receive(:new).and_call_original + + put_revoke + + expect(deploy_token.reload.revoked).to eq(true) + end + + it 'redirects to group repository settings with correct anchor' do + put_revoke + + expect(response).to have_gitlab_http_status(:redirect) + expect(response).to redirect_to(group_settings_repository_path(group, anchor: 'js-deploy-tokens')) + end + end +end diff --git a/spec/requests/groups/harbor/repositories_controller_spec.rb b/spec/requests/groups/harbor/repositories_controller_spec.rb new file mode 100644 index 00000000000..3e475dc410e --- /dev/null +++ b/spec/requests/groups/harbor/repositories_controller_spec.rb @@ -0,0 +1,69 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Groups::Harbor::RepositoriesController do + let_it_be(:group, reload: true) { create(:group) } + let_it_be(:user) { create(:user) } + + shared_examples 'responds with 404 status' do + it 'returns 404' do + subject + + expect(response).to have_gitlab_http_status(:not_found) + end + end + + shared_examples 'responds with 200 status' do + it 'renders the index template' do + subject + + expect(response).to have_gitlab_http_status(:ok) + expect(response).to render_template(:index) + end + end + + before do + stub_feature_flags(harbor_registry_integration: true) + group.add_reporter(user) + login_as(user) + end + + describe 'GET #index' do + subject do + get group_harbor_registries_path(group) + response + end + + context 'with harbor registry feature flag enabled' do + it_behaves_like 'responds with 200 status' + end + + context 'with harbor registry feature flag disabled' do + before do + stub_feature_flags(harbor_registry_integration: false) + end + + it_behaves_like 'responds with 404 status' + end + end + + describe 'GET #show' do + subject do + get group_harbor_registry_path(group, 1) + response + end + + context 'with harbor registry feature flag enabled' do + it_behaves_like 'responds with 200 status' + end + + context 'with harbor registry feature flag disabled' do + before do + stub_feature_flags(harbor_registry_integration: false) + end + + it_behaves_like 'responds with 404 status' + end + end +end |