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>2021-05-19 18:44:42 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-05-19 18:44:42 +0300
commit4555e1b21c365ed8303ffb7a3325d773c9b8bf31 (patch)
tree5423a1c7516cffe36384133ade12572cf709398d /spec/controllers/projects/pipelines_controller_spec.rb
parente570267f2f6b326480d284e0164a6464ba4081bc (diff)
Add latest changes from gitlab-org/gitlab@13-12-stable-eev13.12.0-rc42
Diffstat (limited to 'spec/controllers/projects/pipelines_controller_spec.rb')
-rw-r--r--spec/controllers/projects/pipelines_controller_spec.rb150
1 files changed, 108 insertions, 42 deletions
diff --git a/spec/controllers/projects/pipelines_controller_spec.rb b/spec/controllers/projects/pipelines_controller_spec.rb
index 4a1d01f0e82..0e6b5e84d85 100644
--- a/spec/controllers/projects/pipelines_controller_spec.rb
+++ b/spec/controllers/projects/pipelines_controller_spec.rb
@@ -288,6 +288,17 @@ RSpec.describe Projects::PipelinesController do
get :index, params: { namespace_id: project.namespace, project_id: project }
end
end
+
+ context 'code_quality_walkthrough experiment' do
+ it 'tracks the view', :experiment do
+ expect(experiment(:code_quality_walkthrough))
+ .to track(:view, property: project.root_ancestor.id.to_s)
+ .with_context(namespace: project.root_ancestor)
+ .on_next_instance
+
+ get :index, params: { namespace_id: project.namespace, project_id: project }
+ end
+ end
end
describe 'GET #show' do
@@ -842,10 +853,7 @@ RSpec.describe Projects::PipelinesController do
end
describe 'POST retry.json' do
- let!(:pipeline) { create(:ci_pipeline, :failed, project: project) }
- let!(:build) { create(:ci_build, :failed, pipeline: pipeline) }
-
- before do
+ subject(:post_retry) do
post :retry, params: {
namespace_id: project.namespace,
project_id: project,
@@ -854,15 +862,41 @@ RSpec.describe Projects::PipelinesController do
format: :json
end
- it 'retries a pipeline without returning any content' do
+ let!(:pipeline) { create(:ci_pipeline, :failed, project: project) }
+ let!(:build) { create(:ci_build, :failed, pipeline: pipeline) }
+
+ let(:worker_spy) { class_spy(::Ci::RetryPipelineWorker) }
+
+ before do
+ stub_const('::Ci::RetryPipelineWorker', worker_spy)
+ end
+
+ it 'retries a pipeline in the background without returning any content' do
+ post_retry
+
expect(response).to have_gitlab_http_status(:no_content)
- expect(build.reload).to be_retried
+ expect(::Ci::RetryPipelineWorker).to have_received(:perform_async).with(pipeline.id, user.id)
+ end
+
+ context 'when feature flag is disabled' do
+ before do
+ stub_feature_flags(background_pipeline_retry_endpoint: false)
+ end
+
+ it 'retries the pipeline without returning any content' do
+ post_retry
+
+ expect(response).to have_gitlab_http_status(:no_content)
+ expect(build.reload).to be_retried
+ end
end
context 'when builds are disabled' do
let(:feature) { ProjectFeature::DISABLED }
it 'fails to retry pipeline' do
+ post_retry
+
expect(response).to have_gitlab_http_status(:not_found)
end
end
@@ -976,49 +1010,26 @@ RSpec.describe Projects::PipelinesController do
end
end
- context 'when junit_pipeline_screenshots_view is enabled' do
- before do
- stub_feature_flags(junit_pipeline_screenshots_view: project)
- end
-
- context 'when test_report contains attachment and scope is with_attachment as a URL param' do
- let(:pipeline) { create(:ci_pipeline, :with_test_reports_attachment, project: project) }
+ context 'when test_report contains attachment and scope is with_attachment as a URL param' do
+ let(:pipeline) { create(:ci_pipeline, :with_test_reports_attachment, project: project) }
- it 'returns a test reports with attachment' do
- get_test_report_json(scope: 'with_attachment')
+ it 'returns a test reports with attachment' do
+ get_test_report_json(scope: 'with_attachment')
- expect(response).to have_gitlab_http_status(:ok)
- expect(json_response["test_suites"]).to be_present
- expect(json_response["test_suites"].first["test_cases"].first).to include("attachment_url")
- end
- end
-
- context 'when test_report does not contain attachment and scope is with_attachment as a URL param' do
- let(:pipeline) { create(:ci_pipeline, :with_test_reports, project: project) }
-
- it 'returns a test reports with empty values' do
- get_test_report_json(scope: 'with_attachment')
-
- expect(response).to have_gitlab_http_status(:ok)
- expect(json_response["test_suites"]).to be_empty
- end
+ expect(response).to have_gitlab_http_status(:ok)
+ expect(json_response["test_suites"]).to be_present
+ expect(json_response["test_suites"].first["test_cases"].first).to include("attachment_url")
end
end
- context 'when junit_pipeline_screenshots_view is disabled' do
- before do
- stub_feature_flags(junit_pipeline_screenshots_view: false)
- end
-
- context 'when test_report contains attachment and scope is with_attachment as a URL param' do
- let(:pipeline) { create(:ci_pipeline, :with_test_reports_attachment, project: project) }
+ context 'when test_report does not contain attachment and scope is with_attachment as a URL param' do
+ let(:pipeline) { create(:ci_pipeline, :with_test_reports, project: project) }
- it 'returns a test reports without attachment_url' do
- get_test_report_json(scope: 'with_attachment')
+ it 'returns a test reports with empty values' do
+ get_test_report_json(scope: 'with_attachment')
- expect(response).to have_gitlab_http_status(:ok)
- expect(json_response["test_suites"].first["test_cases"].first).not_to include("attachment_url")
- end
+ expect(response).to have_gitlab_http_status(:ok)
+ expect(json_response["test_suites"]).to be_empty
end
end
@@ -1280,4 +1291,59 @@ RSpec.describe Projects::PipelinesController do
format: :json
end
end
+
+ describe 'GET downloadable_artifacts.json' do
+ context 'when pipeline is empty' do
+ let(:pipeline) { create(:ci_empty_pipeline) }
+
+ it 'returns status not_found' do
+ get_downloadable_artifacts_json
+
+ expect(response).to have_gitlab_http_status(:not_found)
+ end
+ end
+
+ context 'when pipeline exists' do
+ context 'when pipeline does not have any downloadable artifacts' do
+ let(:pipeline) { create(:ci_pipeline, project: project) }
+
+ it 'returns an empty array' do
+ get_downloadable_artifacts_json
+
+ expect(response).to have_gitlab_http_status(:ok)
+ expect(json_response['artifacts']).to be_empty
+ end
+ end
+
+ context 'when pipeline has downloadable artifacts' do
+ let(:pipeline) { create(:ci_pipeline, :with_codequality_reports, project: project) }
+
+ before do
+ create(:ci_build, name: 'rspec', pipeline: pipeline).tap do |build|
+ create(:ci_job_artifact, :junit, job: build)
+ end
+ end
+
+ it 'returns an array of artifacts' do
+ get_downloadable_artifacts_json
+
+ expect(response).to have_gitlab_http_status(:ok)
+ expect(json_response['artifacts']).to be_kind_of(Array)
+ expect(json_response['artifacts'].size).to eq(2)
+ end
+ end
+ end
+
+ private
+
+ def get_downloadable_artifacts_json
+ get :downloadable_artifacts,
+ params: {
+ namespace_id: project.namespace,
+ project_id: project,
+ id: pipeline.id
+ },
+ format: :json
+ end
+ end
end