diff options
author | Bob Van Landuyt <bob@vanlanduyt.co> | 2018-07-03 14:08:46 +0200 |
---|---|---|
committer | Bob Van Landuyt <bob@vanlanduyt.co> | 2018-07-06 09:42:21 +0200 |
commit | a57ec31e4575d5633341143c7b3a4f0a4350c1ec (patch) | |
tree | 5874d93b90059c886389b219ec1f210b7bb96b2a /spec | |
parent | 83f79ced3fd98031194e5667c4d80f66d7987c67 (diff) | |
download | gitlab-ce-a57ec31e4575d5633341143c7b3a4f0a4350c1ec.tar.gz |
Create cross project group features
This allows us to check specific abilities in views, while still
enabling/disabling them at once.
Diffstat (limited to 'spec')
-rw-r--r-- | spec/helpers/groups_helper_spec.rb | 8 | ||||
-rw-r--r-- | spec/policies/group_policy_spec.rb | 6 |
2 files changed, 11 insertions, 3 deletions
diff --git a/spec/helpers/groups_helper_spec.rb b/spec/helpers/groups_helper_spec.rb index 6c94bd4e504..115807f954b 100644 --- a/spec/helpers/groups_helper_spec.rb +++ b/spec/helpers/groups_helper_spec.rb @@ -206,8 +206,9 @@ describe GroupsHelper do let(:group) { create(:group, :public) } let(:user) { create(:user) } before do + group.add_owner(user) allow(helper).to receive(:current_user) { user } - allow(helper).to receive(:can?) { true } + allow(helper).to receive(:can?) { |*args| Ability.allowed?(*args) } helper.instance_variable_set(:@group, group) end @@ -231,7 +232,10 @@ describe GroupsHelper do cross_project_features = [:activity, :issues, :labels, :milestones, :merge_requests] - expect(helper).to receive(:can?).with(user, :read_cross_project) { false } + allow(Ability).to receive(:allowed?).and_call_original + cross_project_features.each do |feature| + expect(Ability).to receive(:allowed?).with(user, "read_group_#{feature}".to_sym, group) { false } + end expect(helper.group_sidebar_links).not_to include(*cross_project_features) end diff --git a/spec/policies/group_policy_spec.rb b/spec/policies/group_policy_spec.rb index 9b5c290b9f9..d6d340bd806 100644 --- a/spec/policies/group_policy_spec.rb +++ b/spec/policies/group_policy_spec.rb @@ -9,7 +9,11 @@ describe GroupPolicy do let(:admin) { create(:admin) } let(:group) { create(:group, :private) } - let(:guest_permissions) { [:read_label, :read_group, :upload_file, :read_namespace] } + let(:guest_permissions) do + [:read_label, :read_group, :upload_file, :read_namespace, :read_group_activity, + :read_group_issues, :read_group_boards, :read_group_labels, :read_group_milestones, + :read_group_merge_requests] + end let(:reporter_permissions) { [:admin_label] } |