From 951616a26a61e880860ad862c1d45a8e3762b4bc Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Tue, 25 Feb 2020 18:09:02 +0000 Subject: Add latest changes from gitlab-org/gitlab@master --- .../admin/serverless/domains_controller_spec.rb | 90 +++++++++++++++++++--- .../remove_cluster_confirmation_spec.js.snap | 9 ++- spec/lib/gitlab/git/blob_spec.rb | 34 ++++++++ spec/lib/gitlab/sidekiq_config/cli_methods_spec.rb | 32 ++++---- spec/models/pages_domain_spec.rb | 1 + .../import_measurement_shared_examples.rb | 31 -------- .../import_export/measurable_shared_examples.rb | 31 ++++++++ .../tasks/gitlab/import_export/export_rake_spec.rb | 37 +++++++++ .../tasks/gitlab/import_export/import_rake_spec.rb | 2 +- 9 files changed, 207 insertions(+), 60 deletions(-) delete mode 100644 spec/support/shared_examples/tasks/gitlab/import_export/import_measurement_shared_examples.rb create mode 100644 spec/support/shared_examples/tasks/gitlab/import_export/measurable_shared_examples.rb create mode 100644 spec/tasks/gitlab/import_export/export_rake_spec.rb (limited to 'spec') diff --git a/spec/controllers/admin/serverless/domains_controller_spec.rb b/spec/controllers/admin/serverless/domains_controller_spec.rb index aed83e190be..43c3f0117bc 100644 --- a/spec/controllers/admin/serverless/domains_controller_spec.rb +++ b/spec/controllers/admin/serverless/domains_controller_spec.rb @@ -15,7 +15,7 @@ describe Admin::Serverless::DomainsController do it 'responds with 404' do get :index - expect(response.status).to eq(404) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -33,7 +33,7 @@ describe Admin::Serverless::DomainsController do it 'responds with 404' do get :index - expect(response.status).to eq(404) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -81,7 +81,7 @@ describe Admin::Serverless::DomainsController do it 'responds with 404' do post :create, params: { pages_domain: create_params } - expect(response.status).to eq(404) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -98,7 +98,7 @@ describe Admin::Serverless::DomainsController do it 'responds with 404' do post :create, params: { pages_domain: create_params } - expect(response.status).to eq(404) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -169,7 +169,7 @@ describe Admin::Serverless::DomainsController do it 'responds with 404' do put :update, params: { id: domain.id, pages_domain: update_params } - expect(response.status).to eq(404) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -186,7 +186,7 @@ describe Admin::Serverless::DomainsController do it 'responds with 404' do put :update, params: { id: domain.id, pages_domain: update_params } - expect(response.status).to eq(404) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -221,7 +221,7 @@ describe Admin::Serverless::DomainsController do it 'returns 404' do put :update, params: { id: 0, pages_domain: update_params } - expect(response.status).to eq(404) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -247,7 +247,7 @@ describe Admin::Serverless::DomainsController do it 'responds with 404' do post :verify, params: { id: domain.id } - expect(response.status).to eq(404) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -272,7 +272,7 @@ describe Admin::Serverless::DomainsController do it 'responds with 404' do post :verify, params: { id: domain.id } - expect(response.status).to eq(404) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -295,4 +295,76 @@ describe Admin::Serverless::DomainsController do end end end + + describe '#destroy' do + let!(:domain) { create(:pages_domain, :instance_serverless) } + + context 'non-admin user' do + before do + sign_in(user) + end + + it 'responds with 404' do + delete :destroy, params: { id: domain.id } + + expect(response).to have_gitlab_http_status(:not_found) + end + end + + context 'admin user' do + before do + sign_in(admin) + end + + context 'with serverless_domain feature disabled' do + before do + stub_feature_flags(serverless_domain: false) + end + + it 'responds with 404' do + delete :destroy, params: { id: domain.id } + + expect(response).to have_gitlab_http_status(:not_found) + end + end + + context 'when domain exists' do + context 'and is not associated to any clusters' do + it 'deletes the domain' do + expect { delete :destroy, params: { id: domain.id } } + .to change { PagesDomain.count }.from(1).to(0) + + expect(response).to have_gitlab_http_status(:found) + expect(flash[:notice]).to include('Domain was successfully deleted.') + end + end + + context 'and is associated to any clusters' do + before do + create(:serverless_domain_cluster, pages_domain: domain) + end + + it 'does not delete the domain' do + expect { delete :destroy, params: { id: domain.id } } + .not_to change { PagesDomain.count } + + expect(response).to have_gitlab_http_status(:conflict) + expect(flash[:notice]).to include('Domain cannot be deleted while associated to one or more clusters.') + end + end + end + + context 'when domain does not exist' do + before do + domain.destroy! + end + + it 'responds with 404' do + delete :destroy, params: { id: domain.id } + + expect(response).to have_gitlab_http_status(:not_found) + end + end + end + end end diff --git a/spec/frontend/clusters/components/__snapshots__/remove_cluster_confirmation_spec.js.snap b/spec/frontend/clusters/components/__snapshots__/remove_cluster_confirmation_spec.js.snap index a35348d86ea..d4269bf14ba 100644 --- a/spec/frontend/clusters/components/__snapshots__/remove_cluster_confirmation_spec.js.snap +++ b/spec/frontend/clusters/components/__snapshots__/remove_cluster_confirmation_spec.js.snap @@ -9,9 +9,12 @@ exports[`Remove cluster confirmation modal renders splitbutton with modal includ class="btn btn-danger" type="button" > - - Remove integration and resources - + + Remove integration and resources + +