Commit 74115b2d authored by mfluharty's avatar mfluharty

Refine based on review feedback

backend:
- add empty show method to controller
- add before_actions to controller for authorization
- add specs for controller and policy

frontend:
- use gl-button class
- pass parameters for download path

docs:
- add introduced line on group page
- clarify and reorder CSV description
parent 6871780d
...@@ -742,6 +742,8 @@ With [GitLab Issue Analytics](issues_analytics/index.md), you can see a bar char ...@@ -742,6 +742,8 @@ With [GitLab Issue Analytics](issues_analytics/index.md), you can see a bar char
## Repositories analytics **(PREMIUM)** ## Repositories analytics **(PREMIUM)**
> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/215104) in [GitLab Premium](https://about.gitlab.com/pricing/) 13.4.
With [GitLab Repositories Analytics](repositories_analytics/index.md), you can download a CSV of the latest coverage data for all the projects in your group. With [GitLab Repositories Analytics](repositories_analytics/index.md), you can download a CSV of the latest coverage data for all the projects in your group.
## Dependency Proxy **(PREMIUM)** ## Dependency Proxy **(PREMIUM)**
......
...@@ -7,17 +7,19 @@ info: To determine the technical writer assigned to the Stage/Group associated w ...@@ -7,17 +7,19 @@ info: To determine the technical writer assigned to the Stage/Group associated w
# Repositories Analytics **(PREMIUM)** # Repositories Analytics **(PREMIUM)**
> - [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/215104) in [GitLab Premium](https://about.gitlab.com/pricing/) 13.3. > [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/215104) in [GitLab Premium](https://about.gitlab.com/pricing/) 13.4.
To get a CSV of the code coverage data for all of the projects in your group, go to your group's **Analytics > CI/CD** page To get a CSV of the code coverage data for all of the projects in your group, go to your group's **Analytics > CI/CD** page, and click **Download historic test coverage data (.csv)**.
Each row in the provided CSV includes: For each day that a coverage report was generated by a job in a project's pipeline, there will be a row in the CSV which includes:
- The date when the coverage was calculated (at most one per day, from the latest run that day) - The date when the coverage job ran
- The name of the project
- The name of the job that generated the coverage report - The name of the job that generated the coverage report
- The name of the project
- The coverage value - The coverage value
If the project's code coverage was calculated more than once in a day, we will take the last value from that day.
<!-- ## Troubleshooting <!-- ## Troubleshooting
Include any troubleshooting steps that you can foresee. If you know beforehand what issues Include any troubleshooting steps that you can foresee. If you know beforehand what issues
......
# frozen_string_literal: true # frozen_string_literal: true
class Groups::Analytics::RepositoryAnalyticsController < Groups::Analytics::ApplicationController class Groups::Analytics::RepositoryAnalyticsController < Groups::Analytics::ApplicationController
layout 'group'
before_action :load_group
before_action -> { check_feature_availability!(:group_coverage_reports) }
before_action -> { check_feature_availability!(:group_repository_analytics) }
before_action -> { authorize_view_by_action!(:read_group_repository_analytics) }
def show
end
end end
...@@ -118,7 +118,7 @@ module EE ...@@ -118,7 +118,7 @@ module EE
def get_group_sidebar_links def get_group_sidebar_links
links = super links = super
resources = [:cycle_analytics, :merge_request_analytics] resources = [:cycle_analytics, :merge_request_analytics, :repository_analytics]
links += resources.select do |resource| links += resources.select do |resource|
can?(current_user, "read_group_#{resource}".to_sym, @group) can?(current_user, "read_group_#{resource}".to_sym, @group)
...@@ -148,10 +148,6 @@ module EE ...@@ -148,10 +148,6 @@ module EE
links << :iterations links << :iterations
end end
if @group.feature_available?(:group_repositories_analytics) && can?(current_user, :read_group_repositories_analytics, @group)
links << :repositories_analytics
end
links links
end end
end end
......
...@@ -7,4 +7,5 @@ ...@@ -7,4 +7,5 @@
.d-flex.justify-content-between.align-items-center .d-flex.justify-content-between.align-items-center
%h4.sub-header %h4.sub-header
= _("Test Code Coverage") = _("Test Code Coverage")
= link_to _("Download historic test coverage data (.csv)"), group_analytics_coverage_reports_path(@group, format: :csv), class: 'btn btn-sm' = link_to _("Download historic test coverage data (.csv)"), group_analytics_coverage_reports_path(@group, format: :csv, ref_path: "refs/heads/master", start_date: Date.today - 1.year, end_date: Date.today),
rel: 'nofollow', download: '', method: :get, class: 'gl-button btn-sm'
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Groups::Analytics::RepositoryAnalyticsController do
let_it_be(:current_user) { create(:user) }
let_it_be(:group) { create :group }
let_it_be(:feature_name) { :group_repository_analytics }
before do
sign_in(current_user)
stub_licensed_features(feature_name => true)
end
describe 'GET show' do
subject { get :show, params: { group_id: group } }
before do
group.add_guest(current_user)
end
it { is_expected.to be_successful }
context 'when license is missing' do
before do
stub_licensed_features(feature_name => false)
end
it { is_expected.to have_gitlab_http_status(:forbidden) }
end
context 'when the user has no access to the group' do
before do
current_user.group_members.delete_all
end
it { is_expected.to have_gitlab_http_status(:forbidden) }
end
end
end
...@@ -194,6 +194,26 @@ RSpec.describe GroupPolicy do ...@@ -194,6 +194,26 @@ RSpec.describe GroupPolicy do
it { is_expected.not_to be_allowed(:read_group_activity_analytics) } it { is_expected.not_to be_allowed(:read_group_activity_analytics) }
end end
context 'when group repository analytics is available' do
let(:current_user) { guest }
before do
stub_licensed_features(group_repository_analytics: true)
end
it { is_expected.to be_allowed(:read_group_repository_analytics) }
end
context 'when group repository analytics is not available' do
let(:current_user) { guest }
before do
stub_licensed_features(group_repository_analytics: false)
end
it { is_expected.not_to be_allowed(:read_group_repository_analytics) }
end
context 'when timelogs report feature is enabled' do context 'when timelogs report feature is enabled' do
before do before do
stub_licensed_features(group_timelogs: true) stub_licensed_features(group_timelogs: true)
......
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