Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/policies/protected_branch_policy_spec.rb')
-rw-r--r--spec/policies/protected_branch_policy_spec.rb40
1 files changed, 10 insertions, 30 deletions
diff --git a/spec/policies/protected_branch_policy_spec.rb b/spec/policies/protected_branch_policy_spec.rb
index d676de14735..d2040a0d334 100644
--- a/spec/policies/protected_branch_policy_spec.rb
+++ b/spec/policies/protected_branch_policy_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
-RSpec.describe ProtectedBranchPolicy do
+RSpec.describe ProtectedBranchPolicy, feature_category: :source_code_management do
let(:user) { create(:user) }
let(:name) { 'feature' }
let(:protected_branch) { create(:protected_branch, name: name) }
@@ -10,47 +10,27 @@ RSpec.describe ProtectedBranchPolicy do
subject { described_class.new(user, protected_branch) }
- context 'as maintainers' do
+ context 'as a maintainer' do
before do
project.add_maintainer(user)
end
- it 'can be read' do
- is_expected.to be_allowed(:read_protected_branch)
- end
-
- it 'can be created' do
- is_expected.to be_allowed(:create_protected_branch)
- end
+ it_behaves_like 'allows protected branch crud'
+ end
- it 'can be updated' do
- is_expected.to be_allowed(:update_protected_branch)
+ context 'as a developer' do
+ before do
+ project.add_developer(user)
end
- it 'can be destroyed' do
- is_expected.to be_allowed(:destroy_protected_branch)
- end
+ it_behaves_like 'disallows protected branch crud'
end
- context 'as guests' do
+ context 'as a guest' do
before do
project.add_guest(user)
end
- it 'can be read' do
- is_expected.to be_disallowed(:read_protected_branch)
- end
-
- it 'can be created' do
- is_expected.to be_disallowed(:create_protected_branch)
- end
-
- it 'can be updated' do
- is_expected.to be_disallowed(:update_protected_branch)
- end
-
- it 'cannot be destroyed' do
- is_expected.to be_disallowed(:destroy_protected_branch)
- end
+ it_behaves_like 'disallows protected branch crud'
end
end