diff options
Diffstat (limited to 'spec/requests/api/ci/pipelines_spec.rb')
-rw-r--r-- | spec/requests/api/ci/pipelines_spec.rb | 69 |
1 files changed, 32 insertions, 37 deletions
diff --git a/spec/requests/api/ci/pipelines_spec.rb b/spec/requests/api/ci/pipelines_spec.rb index c9ca806e2c4..111bc933ea4 100644 --- a/spec/requests/api/ci/pipelines_spec.rb +++ b/spec/requests/api/ci/pipelines_spec.rb @@ -438,7 +438,7 @@ RSpec.describe API::Ci::Pipelines do expect(response).to match_response_schema('public_api/v4/pipeline/detail') end - it 'returns project pipelines' do + it 'returns project pipeline' do get api("/projects/#{project.id}/pipelines/#{pipeline.id}", user) expect(response).to have_gitlab_http_status(:ok) @@ -475,6 +475,20 @@ RSpec.describe API::Ci::Pipelines do expect(json_response['id']).to be nil end end + + context 'when config source is not ci' do + let(:non_ci_config_source) { ::Ci::PipelineEnums.non_ci_config_source_values.first } + let(:pipeline_not_ci) do + create(:ci_pipeline, config_source: non_ci_config_source, project: project) + end + + it 'returns the specified pipeline' do + get api("/projects/#{project.id}/pipelines/#{pipeline_not_ci.id}", user) + + expect(response).to have_gitlab_http_status(:ok) + expect(json_response['sha']).to eq(pipeline_not_ci.sha) + end + end end describe 'GET /projects/:id/pipelines/latest' do @@ -721,55 +735,36 @@ RSpec.describe API::Ci::Pipelines do let(:pipeline) { create(:ci_pipeline, project: project) } - context 'when feature is enabled' do - before do - stub_feature_flags(junit_pipeline_view: true) - end - - context 'when pipeline does not have a test report' do - it 'returns an empty test report' do - subject - - expect(response).to have_gitlab_http_status(:ok) - expect(json_response['total_count']).to eq(0) - end - end - - context 'when pipeline has a test report' do - let(:pipeline) { create(:ci_pipeline, :with_test_reports, project: project) } - - it 'returns the test report' do - subject + context 'when pipeline does not have a test report' do + it 'returns an empty test report' do + subject - expect(response).to have_gitlab_http_status(:ok) - expect(json_response['total_count']).to eq(4) - end + expect(response).to have_gitlab_http_status(:ok) + expect(json_response['total_count']).to eq(0) end + end - context 'when pipeline has corrupt test reports' do - before do - job = create(:ci_build, pipeline: pipeline) - create(:ci_job_artifact, :junit_with_corrupted_data, job: job, project: project) - end + context 'when pipeline has a test report' do + let(:pipeline) { create(:ci_pipeline, :with_test_reports, project: project) } - it 'returns a suite_error' do - subject + it 'returns the test report' do + subject - expect(response).to have_gitlab_http_status(:ok) - expect(json_response['test_suites'].first['suite_error']).to eq('JUnit XML parsing failed: 1:1: FATAL: Document is empty') - end + expect(response).to have_gitlab_http_status(:ok) + expect(json_response['total_count']).to eq(4) end end - context 'when feature is disabled' do + context 'when pipeline has corrupt test reports' do before do - stub_feature_flags(junit_pipeline_view: false) + create(:ci_build, :broken_test_reports, name: 'rspec', pipeline: pipeline) end - it 'renders empty response' do + it 'returns a suite_error' do subject - expect(response).to have_gitlab_http_status(:not_found) + expect(response).to have_gitlab_http_status(:ok) + expect(json_response['test_suites'].first['suite_error']).to eq('JUnit XML parsing failed: 1:1: FATAL: Document is empty') end end end |