Commit 7de245e4 authored by Magdalena Frankiewicz's avatar Magdalena Frankiewicz

Allow auditor to view repository analytics

The auditor role should be able to view repository analytics
of a group they are not a member of, as per our docs.

Changelog: fixed
EE: true
parent a8999822
...@@ -174,6 +174,7 @@ module EE ...@@ -174,6 +174,7 @@ module EE
rule { auditor }.policy do rule { auditor }.policy do
enable :view_productivity_analytics enable :view_productivity_analytics
enable :view_group_devops_adoption enable :view_group_devops_adoption
enable :read_group_repository_analytics
end end
rule { owner | admin }.policy do rule { owner | admin }.policy do
......
...@@ -65,6 +65,12 @@ RSpec.describe Groups::Analytics::RepositoryAnalyticsController do ...@@ -65,6 +65,12 @@ RSpec.describe Groups::Analytics::RepositoryAnalyticsController do
end end
it { is_expected.to have_gitlab_http_status(:forbidden) } it { is_expected.to have_gitlab_http_status(:forbidden) }
context 'when the user is an auditor' do
let(:current_user) { create(:user, :auditor) }
it { is_expected.to have_gitlab_http_status(:success) }
end
end end
end end
end end
...@@ -309,6 +309,12 @@ RSpec.describe GroupPolicy do ...@@ -309,6 +309,12 @@ RSpec.describe GroupPolicy do
it { is_expected.to be_allowed(:read_group_repository_analytics) } it { is_expected.to be_allowed(:read_group_repository_analytics) }
end end
context 'for auditor' do
let(:current_user) { auditor }
it { is_expected.to be_allowed(:read_group_repository_analytics) }
end
end end
context 'when group repository analytics is not available' do context 'when group repository analytics is not available' do
......
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