diff options
Diffstat (limited to 'spec/services/groups/create_service_spec.rb')
-rw-r--r-- | spec/services/groups/create_service_spec.rb | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/spec/services/groups/create_service_spec.rb b/spec/services/groups/create_service_spec.rb index 5cde9a3ed45..c0e876cce33 100644 --- a/spec/services/groups/create_service_spec.rb +++ b/spec/services/groups/create_service_spec.rb @@ -24,6 +24,27 @@ describe Groups::CreateService, '#execute' do end end + context 'creating a group with `default_branch_protection` attribute' do + let(:params) { group_params.merge(default_branch_protection: Gitlab::Access::PROTECTION_NONE) } + let(:service) { described_class.new(user, params) } + let(:created_group) { service.execute } + + context 'for users who have the ability to create a group with `default_branch_protection`' do + it 'creates group with the specified branch protection level' do + expect(created_group.default_branch_protection).to eq(Gitlab::Access::PROTECTION_NONE) + end + end + + context 'for users who do not have the ability to create a group with `default_branch_protection`' do + it 'does not create the group with the specified branch protection level' do + allow(Ability).to receive(:allowed?).and_call_original + allow(Ability).to receive(:allowed?).with(user, :create_group_with_default_branch_protection) { false } + + expect(created_group.default_branch_protection).not_to eq(Gitlab::Access::PROTECTION_NONE) + end + end + end + describe 'creating a top level group' do let(:service) { described_class.new(user, group_params) } |