diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-08-20 18:42:06 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-08-20 18:42:06 +0000 |
commit | 6e4e1050d9dba2b7b2523fdd1768823ab85feef4 (patch) | |
tree | 78be5963ec075d80116a932011d695dd33910b4e /spec/controllers/projects/pipelines_controller_spec.rb | |
parent | 1ce776de4ae122aba3f349c02c17cebeaa8ecf07 (diff) | |
download | gitlab-ce-6e4e1050d9dba2b7b2523fdd1768823ab85feef4.tar.gz |
Add latest changes from gitlab-org/gitlab@13-3-stable-ee
Diffstat (limited to 'spec/controllers/projects/pipelines_controller_spec.rb')
-rw-r--r-- | spec/controllers/projects/pipelines_controller_spec.rb | 224 |
1 files changed, 54 insertions, 170 deletions
diff --git a/spec/controllers/projects/pipelines_controller_spec.rb b/spec/controllers/projects/pipelines_controller_spec.rb index 872f0e97b09..ef560f6426b 100644 --- a/spec/controllers/projects/pipelines_controller_spec.rb +++ b/spec/controllers/projects/pipelines_controller_spec.rb @@ -57,27 +57,6 @@ RSpec.describe Projects::PipelinesController do expect(response).to have_gitlab_http_status(:ok) expect(json_response['pipelines'].count).to eq 12 end - - context 'with build_report_summary turned off' do - before do - stub_feature_flags(build_report_summary: false) - end - - it 'does not execute N+1 queries' do - get_pipelines_index_json - - control_count = ActiveRecord::QueryRecorder.new do - get_pipelines_index_json - end.count - - create_all_pipeline_types - - # There appears to be one extra query for Pipelines#has_warnings? for some reason - expect { get_pipelines_index_json }.not_to exceed_query_limit(control_count + 1) - expect(response).to have_gitlab_http_status(:ok) - expect(json_response['pipelines'].count).to eq 12 - end - end end it 'does not include coverage data for the pipelines' do @@ -880,113 +859,88 @@ RSpec.describe Projects::PipelinesController do end end - context 'when feature is enabled' do - before do - stub_feature_flags(junit_pipeline_view: project) - end - - context 'when pipeline does not have a test report' do - it 'renders an empty test report' do - get_test_report_json + context 'when pipeline does not have a test report' do + it 'renders an empty test report' do + get_test_report_json - expect(response).to have_gitlab_http_status(:ok) - expect(json_response['total_count']).to eq(0) - end + 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 - before do - create(:ci_build, name: 'rspec', pipeline: pipeline).tap do |build| - create(:ci_job_artifact, :junit, job: build) - end - end - - it 'renders the test report' do - get_test_report_json - - expect(response).to have_gitlab_http_status(:ok) - expect(json_response['total_count']).to eq(4) - end + context 'when pipeline has a test report' do + before do + create(:ci_build, :test_reports, name: 'rspec', pipeline: pipeline) end - context 'when pipeline has a corrupt test report artifact' do - before do - create(:ci_build, name: 'rspec', pipeline: pipeline).tap do |build| - create(:ci_job_artifact, :junit_with_corrupted_data, job: build) - end + it 'renders the test report' do + get_test_report_json - get_test_report_json - end + expect(response).to have_gitlab_http_status(:ok) + expect(json_response['total_count']).to eq(4) + end + end - it 'renders the test reports' do - expect(response).to have_gitlab_http_status(:ok) - expect(json_response['test_suites'].count).to eq(1) - end + context 'when pipeline has a corrupt test report artifact' do + before do + create(:ci_build, :broken_test_reports, name: 'rspec', pipeline: pipeline) - it 'returns a suite_error on the suite with corrupted XML' do - expect(json_response['test_suites'].first['suite_error']).to eq('JUnit XML parsing failed: 1:1: FATAL: Document is empty') - end + get_test_report_json 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) } + it 'renders the test reports' do + expect(response).to have_gitlab_http_status(:ok) + expect(json_response['test_suites'].count).to eq(1) + end - it 'returns a test reports with attachment' do - get_test_report_json(scope: 'with_attachment') + it 'returns a suite_error on the suite with corrupted XML' do + expect(json_response['test_suites'].first['suite_error']).to eq('JUnit XML parsing failed: 1:1: FATAL: Document is empty') + end + 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 enabled' do + before do + stub_feature_flags(junit_pipeline_screenshots_view: project) + 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) } + 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 empty values' 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_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 end - context 'when feature is disabled' do - let(:pipeline) { create(:ci_empty_pipeline, project: project) } - + context 'when junit_pipeline_screenshots_view is disabled' do before do - stub_feature_flags(junit_pipeline_view: false) + stub_feature_flags(junit_pipeline_screenshots_view: false) end - it 'renders empty response' do - get_test_report_json + 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 without attachment_url' do + get_test_report_json(scope: 'with_attachment') - expect(response).to have_gitlab_http_status(:no_content) - expect(response.body).to be_empty + expect(response).to have_gitlab_http_status(:ok) + expect(json_response["test_suites"].first["test_cases"].first).not_to include("attachment_url") + end end end @@ -1010,76 +964,6 @@ RSpec.describe Projects::PipelinesController do end end - describe 'GET test_report_count.json' do - subject(:test_reports_count_json) do - get :test_reports_count, params: { - namespace_id: project.namespace, - project_id: project, - id: pipeline.id - }, - format: :json - end - - 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 - let(:pipeline) { create(:ci_pipeline, project: project) } - - it 'renders an empty badge counter' do - test_reports_count_json - - 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 'renders the badge counter value' do - test_reports_count_json - - expect(response).to have_gitlab_http_status(:ok) - expect(json_response['total_count']).to eq(4) - end - end - - context 'when pipeline has corrupt test reports' do - let(:pipeline) { create(:ci_pipeline, project: project) } - - before do - job = create(:ci_build, pipeline: pipeline) - create(:ci_job_artifact, :junit_with_corrupted_data, job: job, project: project) - end - - it 'renders 0' do - test_reports_count_json - - expect(response).to have_gitlab_http_status(:ok) - expect(json_response['total_count']).to eq(0) - end - end - end - - context 'when feature is disabled' do - let(:pipeline) { create(:ci_empty_pipeline, project: project) } - - before do - stub_feature_flags(junit_pipeline_view: false) - end - - it 'renders empty response' do - test_reports_count_json - - expect(response).to have_gitlab_http_status(:no_content) - expect(response.body).to be_empty - end - end - end - describe 'GET latest' do let(:branch_main) { project.repository.branches[0] } let(:branch_secondary) { project.repository.branches[1] } |