blob: 9461f33decbbea3f70a1df52ac9547023b439744 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe ProjectGroupLinkPolicy, feature_category: :system_access do
let_it_be(:user) { create(:user) }
let_it_be(:group) { create(:group, :private) }
let_it_be(:group2) { create(:group, :private) }
let_it_be(:project) { create(:project, :private, group: group) }
let(:project_group_link) do
create(:project_group_link, project: project, group: group2, group_access: Gitlab::Access::DEVELOPER)
end
subject(:policy) { described_class.new(user, project_group_link) }
context 'when the user is a group owner' do
before do
project_group_link.group.add_owner(user)
end
context 'when user is not project maintainer' do
it 'can admin group_project_link' do
expect(policy).to be_allowed(:admin_project_group_link)
end
end
context 'when user is a project maintainer' do
before do
project_group_link.project.add_maintainer(user)
end
it 'can admin group_project_link' do
expect(policy).to be_allowed(:admin_project_group_link)
end
end
end
context 'when user is not a group owner' do
context 'when user is a project maintainer' do
it 'can admin group_project_link' do
project_group_link.project.add_maintainer(user)
expect(policy).to be_allowed(:admin_project_group_link)
end
end
context 'when user is not a project maintainer' do
it 'cannot admin group_project_link' do
project_group_link.project.add_developer(user)
expect(policy).to be_disallowed(:admin_project_group_link)
end
end
end
end
|