Commit addcad9c authored by Aakriti Gupta's avatar Aakriti Gupta Committed by Dmytro Zaporozhets

Make Group Activity Analytics a beta feature

- it will be enbaled per group for beta testing
- finally it can be enabled globally, without
changing this check
parent f90206a9
...@@ -90,8 +90,7 @@ module EE ...@@ -90,8 +90,7 @@ module EE
end end
def show_group_activity_analytics? def show_group_activity_analytics?
::Feature.enabled?(:group_activity_analytics, @group) && can?(current_user, :read_group_activity_analytics, @group)
can?(current_user, :read_group_activity_analytics, @group)
end end
def show_usage_quotas_in_sidebar? def show_usage_quotas_in_sidebar?
......
...@@ -19,7 +19,7 @@ module EE ...@@ -19,7 +19,7 @@ module EE
end end
condition(:group_activity_analytics_available) do condition(:group_activity_analytics_available) do
@subject.feature_available?(:group_activity_analytics) @subject.beta_feature_available?(:group_activity_analytics)
end end
condition(:can_owners_manage_ldap, scope: :global) do condition(:can_owners_manage_ldap, scope: :global) do
......
...@@ -34,9 +34,6 @@ module API ...@@ -34,9 +34,6 @@ module API
end end
get 'issues_count' do get 'issues_count' do
not_found! unless
Feature.enabled?(:group_activity_analytics, group)
authorize! :read_group_activity_analytics, group authorize! :read_group_activity_analytics, group
present( present(
...@@ -55,9 +52,6 @@ module API ...@@ -55,9 +52,6 @@ module API
end end
get 'merge_requests_count' do get 'merge_requests_count' do
not_found! unless
Feature.enabled?(:group_activity_analytics, group)
authorize! :read_group_activity_analytics, group authorize! :read_group_activity_analytics, group
present( present(
...@@ -76,9 +70,6 @@ module API ...@@ -76,9 +70,6 @@ module API
end end
get 'new_members_count' do get 'new_members_count' do
not_found! unless
Feature.enabled?(:group_activity_analytics, group)
authorize! :read_group_activity_analytics, group authorize! :read_group_activity_analytics, group
present( present(
......
...@@ -143,7 +143,11 @@ describe GroupsHelper do ...@@ -143,7 +143,11 @@ describe GroupsHelper do
describe '#show_group_activity_analytics?' do describe '#show_group_activity_analytics?' do
before do before do
allow(Feature).to receive(:enabled?).with(:group_activity_analytics, group).and_return(false)
allow(Feature).to receive(:enabled?).with(:group_activity_analytics).and_return(true)
stub_licensed_features(group_activity_analytics: feature_available) stub_licensed_features(group_activity_analytics: feature_available)
allow(helper).to receive(:current_user) { current_user } allow(helper).to receive(:current_user) { current_user }
allow(helper).to receive(:can?) { |*args| Ability.allowed?(*args) } allow(helper).to receive(:can?) { |*args| Ability.allowed?(*args) }
end end
......
...@@ -92,6 +92,8 @@ describe GroupPolicy do ...@@ -92,6 +92,8 @@ describe GroupPolicy do
let(:current_user) { developer } let(:current_user) { developer }
before do before do
allow(Feature).to receive(:enabled?).with(:group_activity_analytics, group).and_return(false)
stub_licensed_features(group_activity_analytics: true) stub_licensed_features(group_activity_analytics: true)
end end
...@@ -102,6 +104,9 @@ describe GroupPolicy do ...@@ -102,6 +104,9 @@ describe GroupPolicy do
let(:current_user) { developer } let(:current_user) { developer }
before do before do
allow(Feature).to receive(:enabled?).with(:group_activity_analytics, group).and_return(false)
allow(Feature).to receive(:enabled?).with(:group_activity_analytics).and_return(true)
stub_licensed_features(group_activity_analytics: false) stub_licensed_features(group_activity_analytics: false)
end end
......
...@@ -12,7 +12,9 @@ describe API::Analytics::GroupActivityAnalytics do ...@@ -12,7 +12,9 @@ describe API::Analytics::GroupActivityAnalytics do
let_it_be(:anonymous_user) { create(:user) } let_it_be(:anonymous_user) { create(:user) }
shared_examples 'GET group_activity' do |activity, count| shared_examples 'GET group_activity' do |activity, count|
let(:feature_enabled) { true } let(:feature_available) { true }
let(:feature_enabled_globally) { true }
let(:feature_enabled_for_group) { true }
let(:params) { { group_path: group.full_path } } let(:params) { { group_path: group.full_path } }
let(:current_user) { reporter } let(:current_user) { reporter }
let(:request) do let(:request) do
...@@ -20,7 +22,11 @@ describe API::Analytics::GroupActivityAnalytics do ...@@ -20,7 +22,11 @@ describe API::Analytics::GroupActivityAnalytics do
end end
before do before do
stub_licensed_features(group_activity_analytics: feature_enabled) allow(Feature).to receive(:enabled?).with(:group_activity_analytics, group).and_return(feature_enabled_for_group)
allow(Feature).to receive(:enabled?).with(:group_activity_analytics).and_return(feature_enabled_globally)
stub_licensed_features(group_activity_analytics: feature_available)
request request
end end
...@@ -33,7 +39,17 @@ describe API::Analytics::GroupActivityAnalytics do ...@@ -33,7 +39,17 @@ describe API::Analytics::GroupActivityAnalytics do
end end
context 'when feature is not available in plan' do context 'when feature is not available in plan' do
let(:feature_enabled) { false } let(:feature_available) { false }
let(:feature_enabled_for_group) { false }
it 'is returns `forbidden`' do
expect(response).to have_gitlab_http_status(:forbidden)
end
end
context 'when feature is disabled globally' do
let(:feature_enabled_globally) { false }
let(:feature_enabled_for_group) { false }
it 'is returns `forbidden`' do it 'is returns `forbidden`' do
expect(response).to have_gitlab_http_status(:forbidden) expect(response).to have_gitlab_http_status(:forbidden)
......
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