Commit f3ed181b authored by Dmytro Zaporozhets's avatar Dmytro Zaporozhets

Merge branch 'ag-add-helper-for-group-activity' into 'master'

Add visibility helper for Group Activity feature

See merge request gitlab-org/gitlab!26459
parents e0b750f0 bd13066a
...@@ -93,6 +93,14 @@ module EE ...@@ -93,6 +93,14 @@ module EE
current_user.ab_feature_enabled?(:discover_security) current_user.ab_feature_enabled?(:discover_security)
end end
def show_group_activity_analytics?
return false unless @group.feature_available?(:group_activity_analytics)
return false unless can?(current_user, :read_group_activity_analytics, @group)
true
end
private private
def get_group_sidebar_links def get_group_sidebar_links
......
...@@ -138,4 +138,37 @@ describe GroupsHelper do ...@@ -138,4 +138,37 @@ describe GroupsHelper do
end end
end end
end end
describe '#show_group_activity_analytics?' do
before do
stub_licensed_features(group_activity_analytics: feature_available)
allow(helper).to receive(:current_user) { current_user }
allow(helper).to receive(:can?) { |*args| Ability.allowed?(*args) }
end
context 'when feature is not available for group' do
let(:feature_available) { false }
it 'returns false' do
expect(helper.show_group_activity_analytics?).to be false
end
end
context 'when current user does not have access to the group' do
let(:feature_available) { true }
let(:current_user) { create(:user) }
it 'returns false' do
expect(helper.show_group_activity_analytics?).to be false
end
end
context 'when feature is available and user has access to it' do
let(:feature_available) { true }
it 'returns true' do
expect(helper.show_group_activity_analytics?).to be true
end
end
end
end end
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