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 ...@@ -154,6 +154,8 @@ class Projects::PipelinesController < Projects::ApplicationController
end end
def test_report def test_report
return unless Feature.enabled?(:junit_pipeline_view, project)
if pipeline_test_report == :error if pipeline_test_report == :error
render json: { status: :error_parsing_report } render json: { status: :error_parsing_report }
return return
......
...@@ -408,41 +408,62 @@ describe Projects::PipelinesController do ...@@ -408,41 +408,62 @@ describe Projects::PipelinesController do
format: :json format: :json
end end
context 'when pipeline does not have a test report' do context 'when feature is enabled' do
let(:pipeline) { create(:ci_pipeline, project: project) } before do
stub_feature_flags(junit_pipeline_view: true)
end
it 'renders an empty test report' do context 'when pipeline does not have a test report' do
get_test_report_json let(:pipeline) { create(:ci_pipeline, project: project) }
expect(response).to have_gitlab_http_status(:ok) it 'renders an empty test report' do
expect(json_response['total_count']).to eq(0) get_test_report_json
expect(response).to have_gitlab_http_status(:ok)
expect(json_response['total_count']).to eq(0)
end
end end
end
context 'when pipeline has a test report' do context 'when pipeline has a test report' do
let(:pipeline) { create(:ci_pipeline, :with_test_reports, project: project) } let(:pipeline) { create(:ci_pipeline, :with_test_reports, project: project) }
it 'renders the test report' do it 'renders the test report' do
get_test_report_json get_test_report_json
expect(response).to have_gitlab_http_status(:ok) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['total_count']).to eq(4) 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
end end
context 'when pipeline has corrupt test reports' do context 'when feature is disabled' do
let(:pipeline) { create(:ci_pipeline, project: project) } let(:pipeline) { create(:ci_empty_pipeline, project: project) }
before do before do
job = create(:ci_build, pipeline: pipeline) stub_feature_flags(junit_pipeline_view: false)
create(:ci_job_artifact, :junit_with_corrupted_data, job: job, project: project)
end end
it 'renders the test reports' do it 'renders empty response' do
get_test_report_json get_test_report_json
expect(response).to have_gitlab_http_status(:ok) expect(response).to have_gitlab_http_status(:no_content)
expect(json_response['status']).to eq('error_parsing_report') expect(response.body).to be_empty
end end
end 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