Commit 97532bc2 authored by Aakriti Gupta's avatar Aakriti Gupta Committed by Dmytro Zaporozhets

Add policy for Group Activity Analytics feature

The policy is set per group.

This also adds license for the feature for EE Starter/
Bronze users
parent 49e8c80f
......@@ -17,6 +17,7 @@ class License < ApplicationRecord
description_diffs
elastic_search
export_issues
group_activity_analytics
group_bulk_edit
group_burndown_charts
group_webhooks
......
......@@ -18,6 +18,10 @@ module EE
@subject.feature_available?(:cycle_analytics_for_groups)
end
condition(:group_activity_analytics_available) do
@subject.feature_available?(:group_activity_analytics)
end
condition(:can_owners_manage_ldap, scope: :global) do
::Gitlab::CurrentSettings.allow_group_owners_to_manage_ldap?
end
......@@ -78,6 +82,9 @@ module EE
rule { can?(:read_group) & contribution_analytics_available }
.enable :read_group_contribution_analytics
rule { can?(:read_group) & group_activity_analytics_available }
.enable :read_group_activity_analytics
rule { reporter & cycle_analytics_available }.policy do
enable :read_group_cycle_analytics, :create_group_stage, :read_group_stage, :update_group_stage, :delete_group_stage
end
......
......@@ -61,6 +61,26 @@ describe GroupPolicy do
it { is_expected.not_to be_allowed(:read_group_contribution_analytics) }
end
context 'when group activity analytics is available' do
let(:current_user) { developer }
before do
stub_licensed_features(group_activity_analytics: true)
end
it { is_expected.to be_allowed(:read_group_activity_analytics) }
end
context 'when group activity analytics is not available' do
let(:current_user) { developer }
before do
stub_licensed_features(group_activity_analytics: false)
end
it { is_expected.not_to be_allowed(:read_group_activity_analytics) }
end
context 'when timelogs report feature is enabled' do
before do
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