Commit 768d4f55 authored by Matija Čupić's avatar Matija Čupić

Feature gate PipelinesController#test_report

parent 226467f2
......@@ -154,6 +154,8 @@ class Projects::PipelinesController < Projects::ApplicationController
end
def test_report
return unless Feature.enabled?(:junit_pipeline_view, project)
if pipeline_test_report == :error
render json: { status: :error_parsing_report }
return
......
......@@ -408,41 +408,62 @@ describe Projects::PipelinesController do
format: :json
end
context 'when pipeline does not have a test report' do
let(:pipeline) { create(:ci_pipeline, project: project) }
context 'when feature is enabled' do
before do
stub_feature_flags(junit_pipeline_view: true)
end
it 'renders an empty test report' do
get_test_report_json
context 'when pipeline does not have a test report' do
let(:pipeline) { create(:ci_pipeline, project: project) }
expect(response).to have_gitlab_http_status(:ok)
expect(json_response['total_count']).to eq(0)
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
end
end
context 'when pipeline has a test report' do
let(:pipeline) { create(:ci_pipeline, :with_test_reports, project: project) }
context 'when pipeline has a test report' do
let(:pipeline) { create(:ci_pipeline, :with_test_reports, project: project) }
it 'renders the test report' do
get_test_report_json
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)
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 the test reports' do
get_test_report_json
expect(response).to have_gitlab_http_status(:ok)
expect(json_response['status']).to eq('error_parsing_report')
end
end
end
context 'when pipeline has corrupt test reports' do
let(:pipeline) { create(:ci_pipeline, project: project) }
context 'when feature is disabled' do
let(:pipeline) { create(:ci_empty_pipeline, project: project) }
before do
job = create(:ci_build, pipeline: pipeline)
create(:ci_job_artifact, :junit_with_corrupted_data, job: job, project: project)
stub_feature_flags(junit_pipeline_view: false)
end
it 'renders the test reports' do
it 'renders empty response' do
get_test_report_json
expect(response).to have_gitlab_http_status(:ok)
expect(json_response['status']).to eq('error_parsing_report')
expect(response).to have_gitlab_http_status(:no_content)
expect(response.body).to be_empty
end
end
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment