summaryrefslogtreecommitdiff
path: root/spec/controllers
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-02-25 18:09:02 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-02-25 18:09:02 +0000
commit951616a26a61e880860ad862c1d45a8e3762b4bc (patch)
treeed6fe722e955aff38e13ca02d2aa7fdd4239c863 /spec/controllers
parente06d0e779673d745972863302858105aad9032e5 (diff)
downloadgitlab-ce-951616a26a61e880860ad862c1d45a8e3762b4bc.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/controllers')
-rw-r--r--spec/controllers/admin/serverless/domains_controller_spec.rb90
1 files changed, 81 insertions, 9 deletions
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