diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-11 12:08:39 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-11 12:08:39 +0300 |
commit | 1078b7bf25c2cb6e03c57da9ae25b0512858556f (patch) | |
tree | a50fbfaddb22aca89055296c4c532c7ecb2b1ca0 /spec/controllers | |
parent | 55733b19c526145cceb120e8bb874d476a84383a (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/controllers')
-rw-r--r-- | spec/controllers/projects/pipelines_controller_spec.rb | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/spec/controllers/projects/pipelines_controller_spec.rb b/spec/controllers/projects/pipelines_controller_spec.rb index b12af198986..fbb77304ce9 100644 --- a/spec/controllers/projects/pipelines_controller_spec.rb +++ b/spec/controllers/projects/pipelines_controller_spec.rb @@ -682,6 +682,76 @@ 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] } |