diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-12-17 14:59:07 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-12-17 14:59:07 +0300 |
commit | 8b573c94895dc0ac0e1d9d59cf3e8745e8b539ca (patch) | |
tree | 544930fb309b30317ae9797a9683768705d664c4 /spec/controllers/admin | |
parent | 4b1de649d0168371549608993deac953eb692019 (diff) |
Add latest changes from gitlab-org/gitlab@13-7-stable-eev13.7.0-rc42
Diffstat (limited to 'spec/controllers/admin')
5 files changed, 117 insertions, 4 deletions
diff --git a/spec/controllers/admin/application_settings_controller_spec.rb b/spec/controllers/admin/application_settings_controller_spec.rb index f71f859a704..f0b224484c6 100644 --- a/spec/controllers/admin/application_settings_controller_spec.rb +++ b/spec/controllers/admin/application_settings_controller_spec.rb @@ -157,6 +157,44 @@ RSpec.describe Admin::ApplicationSettingsController do expect(ApplicationSetting.current.default_branch_name).to eq("example_branch_name") end + context "personal access token prefix settings" do + let(:application_settings) { ApplicationSetting.current } + + shared_examples "accepts prefix setting" do |prefix| + it "updates personal_access_token_prefix setting" do + put :update, params: { application_setting: { personal_access_token_prefix: prefix } } + + expect(response).to redirect_to(general_admin_application_settings_path) + expect(application_settings.reload.personal_access_token_prefix).to eq(prefix) + end + end + + shared_examples "rejects prefix setting" do |prefix| + it "does not update personal_access_token_prefix setting" do + put :update, params: { application_setting: { personal_access_token_prefix: prefix } } + + expect(response).not_to redirect_to(general_admin_application_settings_path) + expect(application_settings.reload.personal_access_token_prefix).not_to eq(prefix) + end + end + + context "with valid prefix" do + include_examples("accepts prefix setting", "a_prefix@") + end + + context "with blank prefix" do + include_examples("accepts prefix setting", "") + end + + context "with too long prefix" do + include_examples("rejects prefix setting", "a_prefix@" * 10) + end + + context "with invalid characters prefix" do + include_examples("rejects prefix setting", "a_préfixñ:") + end + end + context 'external policy classification settings' do let(:settings) do { diff --git a/spec/controllers/admin/clusters/applications_controller_spec.rb b/spec/controllers/admin/clusters/applications_controller_spec.rb index 2a77693061c..d1ca64d6bd2 100644 --- a/spec/controllers/admin/clusters/applications_controller_spec.rb +++ b/spec/controllers/admin/clusters/applications_controller_spec.rb @@ -22,7 +22,7 @@ RSpec.describe Admin::Clusters::ApplicationsController do post :create, params: params end - let(:application) { 'helm' } + let(:application) { 'ingress' } let(:params) { { application: application, id: cluster.id } } describe 'functionality' do @@ -37,7 +37,7 @@ RSpec.describe Admin::Clusters::ApplicationsController do expect { subject }.to change { current_application.count } expect(response).to have_gitlab_http_status(:no_content) - expect(cluster.application_helm).to be_scheduled + expect(cluster.application_ingress).to be_scheduled end context 'when cluster do not exists' do @@ -61,7 +61,7 @@ RSpec.describe Admin::Clusters::ApplicationsController do context 'when application is already installing' do before do - create(:clusters_applications_helm, :installing, cluster: cluster) + create(:clusters_applications_ingress, :installing, cluster: cluster) end it 'returns 400' do diff --git a/spec/controllers/admin/clusters_controller_spec.rb b/spec/controllers/admin/clusters_controller_spec.rb index 69bdc79c5f5..85aa77d8473 100644 --- a/spec/controllers/admin/clusters_controller_spec.rb +++ b/spec/controllers/admin/clusters_controller_spec.rb @@ -341,7 +341,7 @@ RSpec.describe Admin::ClustersController do expect { post_create_aws }.not_to change { Clusters::Cluster.count } expect(response).to have_gitlab_http_status(:unprocessable_entity) - expect(response.content_type).to eq('application/json') + expect(response.media_type).to eq('application/json') expect(response.body).to include('is invalid') end end diff --git a/spec/controllers/admin/integrations_controller_spec.rb b/spec/controllers/admin/integrations_controller_spec.rb index 1a13d016b73..e14619a9916 100644 --- a/spec/controllers/admin/integrations_controller_spec.rb +++ b/spec/controllers/admin/integrations_controller_spec.rb @@ -73,4 +73,28 @@ RSpec.describe Admin::IntegrationsController do end end end + + describe '#reset' do + let_it_be(:integration) { create(:jira_service, :instance) } + let_it_be(:inheriting_integration) { create(:jira_service, inherit_from_id: integration.id) } + + subject do + post :reset, params: { id: integration.class.to_param } + end + + it 'returns 200 OK', :aggregate_failures do + subject + + expected_json = {}.to_json + + expect(flash[:notice]).to eq('This integration, and inheriting projects were reset.') + expect(response).to have_gitlab_http_status(:ok) + expect(response.body).to eq(expected_json) + end + + it 'deletes the integration and all inheriting integrations' do + expect { subject }.to change { JiraService.for_instance.count }.by(-1) + .and change { JiraService.inherit_from_id(integration.id).count }.by(-1) + end + end end diff --git a/spec/controllers/admin/users_controller_spec.rb b/spec/controllers/admin/users_controller_spec.rb index d0d1fa6a6bc..f902a3d2541 100644 --- a/spec/controllers/admin/users_controller_spec.rb +++ b/spec/controllers/admin/users_controller_spec.rb @@ -102,6 +102,57 @@ RSpec.describe Admin::UsersController do end end + describe 'DELETE #reject' do + subject { put :reject, params: { id: user.username } } + + context 'when rejecting a pending user' do + let(:user) { create(:user, :blocked_pending_approval) } + + it 'hard deletes the user', :sidekiq_inline do + subject + + expect(User.exists?(user.id)).to be_falsy + end + + it 'displays the rejection message' do + subject + + expect(response).to redirect_to(admin_users_path) + expect(flash[:notice]).to eq("You've rejected #{user.name}") + end + + it 'sends the user a rejection email' do + expect_next_instance_of(NotificationService) do |notification| + allow(notification).to receive(:user_admin_rejection).with(user.name, user.notification_email) + end + + subject + end + end + + context 'when user is not pending' do + let(:user) { create(:user, state: 'active') } + + it 'does not reject and delete the user' do + subject + + expect(User.exists?(user.id)).to be_truthy + end + + it 'displays the error' do + subject + + expect(flash[:alert]).to eq('This user does not have a pending request') + end + + it 'does not email the user' do + expect(NotificationService).not_to receive(:new) + + subject + end + end + end + describe 'PUT #approve' do let(:user) { create(:user, :blocked_pending_approval) } |