Commit d1234bb2 authored by Kamil Trzciński's avatar Kamil Trzciński

Merge branch 'mc/cleanup-metrics-ff' into 'master'

Remove Metrics feature flag gate

Closes #9788

See merge request gitlab-org/gitlab-ee!11131
parents d6d93fe2 6635c5f0
......@@ -43,10 +43,6 @@ module EE
end
def metrics_reports
unless ::Feature.enabled?(:metrics_reports, project)
return render json: '', status: :bad_request
end
reports_response(merge_request.compare_metrics_reports)
end
......
......@@ -403,6 +403,8 @@ describe Projects::MergeRequestsController do
end
describe 'GET #metrics_reports' do
let(:merge_request) { create(:ee_merge_request, :with_metrics_reports, source_project: project, author: create(:user)) }
let(:params) do
{
namespace_id: project.namespace.to_param,
......@@ -413,91 +415,75 @@ describe Projects::MergeRequestsController do
subject { get :metrics_reports, params: params, format: :json }
context 'when feature is enabled' do
let(:merge_request) { create(:ee_merge_request, :with_metrics_reports, source_project: project, author: create(:user)) }
before do
allow_any_instance_of(::MergeRequest).to receive(:compare_reports)
.with(::Ci::CompareMetricsReportsService).and_return(comparison_status)
end
context 'when comparison is being processed' do
let(:comparison_status) { { status: :parsing } }
it 'sends polling interval' do
expect(::Gitlab::PollingInterval).to receive(:set_header)
before do
allow_any_instance_of(::MergeRequest).to receive(:compare_reports)
.with(::Ci::CompareMetricsReportsService).and_return(comparison_status)
end
subject
end
context 'when comparison is being processed' do
let(:comparison_status) { { status: :parsing } }
it 'returns 204 HTTP status' do
subject
it 'sends polling interval' do
expect(::Gitlab::PollingInterval).to receive(:set_header)
expect(response).to have_gitlab_http_status(:no_content)
end
subject
end
context 'when comparison is done' do
let(:comparison_status) { { status: :parsed, data: { summary: 1 } } }
it 'does not send polling interval' do
expect(::Gitlab::PollingInterval).not_to receive(:set_header)
subject
end
it 'returns 200 HTTP status' do
subject
it 'returns 204 HTTP status' do
subject
expect(response).to have_gitlab_http_status(:ok)
expect(json_response).to eq({ 'summary' => 1 })
end
expect(response).to have_gitlab_http_status(:no_content)
end
end
context 'when user created corrupted test reports' do
let(:comparison_status) { { status: :error, status_reason: 'Failed to parse test reports' } }
context 'when comparison is done' do
let(:comparison_status) { { status: :parsed, data: { summary: 1 } } }
it 'does not send polling interval' do
expect(::Gitlab::PollingInterval).not_to receive(:set_header)
it 'does not send polling interval' do
expect(::Gitlab::PollingInterval).not_to receive(:set_header)
subject
end
subject
end
it 'returns 400 HTTP status' do
subject
it 'returns 200 HTTP status' do
subject
expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response).to eq({ 'status_reason' => 'Failed to parse test reports' })
end
expect(response).to have_gitlab_http_status(:ok)
expect(json_response).to eq({ 'summary' => 1 })
end
end
context 'when something went wrong on our system' do
let(:comparison_status) { {} }
context 'when user created corrupted test reports' do
let(:comparison_status) { { status: :error, status_reason: 'Failed to parse test reports' } }
it 'does not send polling interval' do
expect(::Gitlab::PollingInterval).not_to receive(:set_header)
it 'does not send polling interval' do
expect(::Gitlab::PollingInterval).not_to receive(:set_header)
subject
end
subject
end
it 'returns 500 HTTP status' do
subject
it 'returns 400 HTTP status' do
subject
expect(response).to have_gitlab_http_status(:internal_server_error)
expect(json_response).to eq({ 'status_reason' => 'Unknown error' })
end
expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response).to eq({ 'status_reason' => 'Failed to parse test reports' })
end
end
context 'when feature is not enabled' do
before do
stub_feature_flags(metrics_reports: false)
context 'when something went wrong on our system' do
let(:comparison_status) { {} }
it 'does not send polling interval' do
expect(::Gitlab::PollingInterval).not_to receive(:set_header)
subject
end
it 'returns no content' do
it 'returns 500 HTTP status' do
subject
expect(response).to have_gitlab_http_status(:bad_request)
expect(response).to have_gitlab_http_status(:internal_server_error)
expect(json_response).to eq({ 'status_reason' => 'Unknown error' })
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