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