Commit 1f9caf4b authored by drew cimino's avatar drew cimino

Restrict Group CoverageReports#index to coverage data

parent c283e982
......@@ -4,10 +4,10 @@ class Groups::Analytics::CoverageReportsController < Groups::Analytics::Applicat
check_feature_flag Gitlab::Analytics::CYCLE_ANALYTICS_FEATURE_FLAG
REPORT_WINDOW = 90.days.freeze
COVERAGE_PARAM = 'coverage'.freeze
before_action :load_group
before_action -> { check_feature_availability!(:group_coverage_reports) }
before_action :validate_param_type!
def index
respond_to do |format|
......@@ -28,7 +28,7 @@ class Groups::Analytics::CoverageReportsController < Groups::Analytics::Applicat
date: 'date',
group_name: 'group_name',
project_name: -> (record) { record.project.name },
param_type => -> (record) { record.data[param_type] }
COVERAGE_PARAM => -> (record) { record.data[COVERAGE_PARAM] }
}
).render
end
......@@ -65,8 +65,4 @@ class Groups::Analytics::CoverageReportsController < Groups::Analytics::Applicat
def allowed_param_types
Ci::DailyBuildGroupReportResult::PARAM_TYPES
end
def param_type
params.require(:param_type)
end
end
......@@ -11,10 +11,9 @@ RSpec.describe Groups::Analytics::CoverageReportsController do
let!(:first_coverage) { create_daily_coverage('rspec', 79.0, '2020-03-09') }
let!(:last_coverage) { create_daily_coverage('karma', 95.0, '2020-03-10') }
let(:index_request) do
get :index, params: {
let(:valid_request_params) do
{
group_id: group.name,
param_type: 'coverage',
start_date: '2020-03-01',
end_date: '2020-03-31',
ref_path: ref_path,
......@@ -29,7 +28,7 @@ RSpec.describe Groups::Analytics::CoverageReportsController do
describe 'GET index' do
it 'responds 403' do
index_request
get :index, params: valid_request_params
expect(response).to have_gitlab_http_status(:forbidden)
end
......@@ -49,7 +48,7 @@ RSpec.describe Groups::Analytics::CoverageReportsController do
describe 'GET index' do
it 'responds 403 because the feature is not licensed' do
index_request
get :index, params: valid_request_params
expect(response).to have_gitlab_http_status(:forbidden)
end
......@@ -64,7 +63,7 @@ RSpec.describe Groups::Analytics::CoverageReportsController do
describe 'GET index' do
it 'responds 403 because the feature is not licensed' do
index_request
get :index, params: valid_request_params
expect(response).to have_gitlab_http_status(:forbidden)
end
......@@ -77,7 +76,7 @@ RSpec.describe Groups::Analytics::CoverageReportsController do
end
it 'responds 200 with CSV coverage data' do
index_request
get :index, params: valid_request_params
expect(response).to have_gitlab_http_status(:ok)
expect(csv_response).to eq([
......
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