Commit 6c7059be authored by Jason Goodman's avatar Jason Goodman Committed by Dan Davison

Update group policy pending membership specs

Test each role rather than just developer
parent 343607b5
...@@ -1812,7 +1812,9 @@ RSpec.describe GroupPolicy do ...@@ -1812,7 +1812,9 @@ RSpec.describe GroupPolicy do
end end
end end
describe 'pending memberships' do describe 'a pending membership' do
using RSpec::Parameterized::TableSyntax
let_it_be(:user) { create(:user) } let_it_be(:user) { create(:user) }
context 'with a private group' do context 'with a private group' do
...@@ -1820,19 +1822,29 @@ RSpec.describe GroupPolicy do ...@@ -1820,19 +1822,29 @@ RSpec.describe GroupPolicy do
subject { described_class.new(user, private_group) } subject { described_class.new(user, private_group) }
context 'developer' do where(:role) do
before do Gitlab::Access.sym_options_with_owner.keys.map(&:to_sym)
create(:group_member, :awaiting, :developer, source: private_group, user: user) end
end
with_them do
it 'has permission identical to a private group in which the user is not a member' do it 'has permission identical to a private group in which the user is not a member' do
create(:group_member, :awaiting, role, source: private_group, user: user)
expect_private_group_permissions_as_if_non_member expect_private_group_permissions_as_if_non_member
end end
end
context 'with a project in the group' do
let_it_be(:project) { create(:project, :private, namespace: private_group) }
context 'with a project in the group' do where(:role) do
let_it_be(:project) { create(:project, :private, namespace: private_group) } Gitlab::Access.sym_options_with_owner.keys.map(&:to_sym)
end
with_them do
it 'has permission identical to a private group in which the user is not a member' do it 'has permission identical to a private group in which the user is not a member' do
create(:group_member, :awaiting, role, source: private_group, user: user)
expect_private_group_permissions_as_if_non_member expect_private_group_permissions_as_if_non_member
end end
end end
...@@ -1844,12 +1856,14 @@ RSpec.describe GroupPolicy do ...@@ -1844,12 +1856,14 @@ RSpec.describe GroupPolicy do
subject { described_class.new(user, public_group) } subject { described_class.new(user, public_group) }
context 'developer' do where(:role) do
before do Gitlab::Access.sym_options_with_owner.keys.map(&:to_sym)
create(:group_member, :awaiting, :developer, source: public_group, user: user) end
end
with_them do
it 'has permission identical to a public group in which the user is not a member' do it 'has permission identical to a public group in which the user is not a member' do
create(:group_member, :awaiting, role, source: public_group, user: user)
expect_allowed(*public_permissions) expect_allowed(*public_permissions)
expect_disallowed(:upload_file) expect_disallowed(:upload_file)
expect_disallowed(*reporter_permissions) expect_disallowed(*reporter_permissions)
...@@ -1862,8 +1876,6 @@ RSpec.describe GroupPolicy do ...@@ -1862,8 +1876,6 @@ RSpec.describe GroupPolicy do
end end
context 'with a group invited to another group' do context 'with a group invited to another group' do
using RSpec::Parameterized::TableSyntax
let_it_be(:group) { create(:group, :public) } let_it_be(:group) { create(:group, :public) }
let_it_be(:other_group) { create(:group, :private) } let_it_be(:other_group) { create(:group, :private) }
...@@ -1874,11 +1886,11 @@ RSpec.describe GroupPolicy do ...@@ -1874,11 +1886,11 @@ RSpec.describe GroupPolicy do
end end
where(:role) do where(:role) do
%i(owner maintainer developer reporter guest) Gitlab::Access.sym_options_with_owner.keys.map(&:to_sym)
end end
with_them do with_them do
it 'a pending member in the group has permissions to the other group as if the user is not a member' do it 'has permission to the other group as if the user is not a member' do
create(:group_member, :awaiting, role, source: group, user: user) create(:group_member, :awaiting, role, source: group, user: user)
expect_private_group_permissions_as_if_non_member expect_private_group_permissions_as_if_non_member
......
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