Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-01-13 18:07:53 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-01-13 18:07:53 +0300
commita5ab3467a705b62911feacc3cf627fdbb00aa198 (patch)
tree65143ce13405efccb922fc428624ad57c38b6efa /spec/requests/self_monitoring_project_spec.rb
parenteb30dd6e28f6fc9eb8021d205f6ed84511f001e2 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/requests/self_monitoring_project_spec.rb')
-rw-r--r--spec/requests/self_monitoring_project_spec.rb108
1 files changed, 107 insertions, 1 deletions
diff --git a/spec/requests/self_monitoring_project_spec.rb b/spec/requests/self_monitoring_project_spec.rb
index f3ffa8e0ea4..d562a34aec4 100644
--- a/spec/requests/self_monitoring_project_spec.rb
+++ b/spec/requests/self_monitoring_project_spec.rb
@@ -60,7 +60,7 @@ describe 'Self-Monitoring project requests' do
end
it_behaves_like 'sets polling header and returns accepted' do
- let(:in_progress_message) { 'Job is in progress' }
+ let(:in_progress_message) { 'Job to create self-monitoring project is in progress' }
end
end
@@ -115,4 +115,110 @@ describe 'Self-Monitoring project requests' do
end
end
end
+
+ describe 'DELETE #delete_self_monitoring_project' do
+ let(:worker_class) { SelfMonitoringProjectDeleteWorker }
+
+ subject { delete delete_self_monitoring_project_admin_application_settings_path }
+
+ it_behaves_like 'not accessible to non-admin users'
+
+ context 'with admin user' do
+ before do
+ login_as(admin)
+ end
+
+ context 'with feature flag disabled' do
+ it_behaves_like 'not accessible if feature flag is disabled'
+ end
+
+ context 'with feature flag enabled' do
+ let(:status_api) { status_delete_self_monitoring_project_admin_application_settings_path }
+
+ it_behaves_like 'triggers async worker, returns sidekiq job_id with response accepted'
+ end
+ end
+ end
+
+ describe 'GET #status_delete_self_monitoring_project' do
+ let(:worker_class) { SelfMonitoringProjectDeleteWorker }
+ let(:job_id) { 'job_id' }
+
+ subject do
+ get status_delete_self_monitoring_project_admin_application_settings_path,
+ params: { job_id: job_id }
+ end
+
+ it_behaves_like 'not accessible to non-admin users'
+
+ context 'with admin user' do
+ before do
+ login_as(admin)
+ end
+
+ context 'with feature flag disabled' do
+ it_behaves_like 'not accessible if feature flag is disabled'
+ end
+
+ context 'with feature flag enabled' do
+ it_behaves_like 'handles invalid job_id'
+
+ context 'when job is in progress' do
+ before do
+ allow(worker_class).to receive(:in_progress?)
+ .with(job_id)
+ .and_return(true)
+
+ stub_application_setting(instance_administration_project_id: 1)
+ end
+
+ it_behaves_like 'sets polling header and returns accepted' do
+ let(:in_progress_message) { 'Job to delete self-monitoring project is in progress' }
+ end
+ end
+
+ context 'when self-monitoring project exists and job does not exist' do
+ before do
+ stub_application_setting(instance_administration_project_id: 1)
+ end
+
+ it 'returns bad_request' do
+ subject
+
+ aggregate_failures do
+ expect(response).to have_gitlab_http_status(:bad_request)
+ expect(json_response).to eq(
+ 'message' => 'Self-monitoring project was not deleted. Please check logs ' \
+ 'for any error messages'
+ )
+ end
+ end
+ end
+
+ context 'when self-monitoring project does not exist' do
+ it 'does not need job_id' do
+ get status_delete_self_monitoring_project_admin_application_settings_path
+
+ aggregate_failures do
+ expect(response).to have_gitlab_http_status(:success)
+ expect(json_response).to eq(
+ 'message' => 'Self-monitoring project has been successfully deleted'
+ )
+ end
+ end
+
+ it 'returns success with job_id' do
+ subject
+
+ aggregate_failures do
+ expect(response).to have_gitlab_http_status(:success)
+ expect(json_response).to eq(
+ 'message' => 'Self-monitoring project has been successfully deleted'
+ )
+ end
+ end
+ end
+ end
+ end
+ end
end