summaryrefslogtreecommitdiff
path: root/spec/policies
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-05-04 13:41:07 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2022-05-04 13:41:07 +0000
commit4f791ec8bd51d2bacada5ba48334c16076cf91b8 (patch)
tree89c61fbbfdc63b8d920787f78ff226967b87d7b8 /spec/policies
parent056dd422ea9e03869c182a9200fcbe9166d01ad1 (diff)
downloadgitlab-ce-4f791ec8bd51d2bacada5ba48334c16076cf91b8.tar.gz
Add latest changes from gitlab-org/gitlab@14-10-stable-ee
Diffstat (limited to 'spec/policies')
-rw-r--r--spec/policies/project_policy_spec.rb88
1 files changed, 69 insertions, 19 deletions
diff --git a/spec/policies/project_policy_spec.rb b/spec/policies/project_policy_spec.rb
index bde83d647db..ca4ca2eb7a0 100644
--- a/spec/policies/project_policy_spec.rb
+++ b/spec/policies/project_policy_spec.rb
@@ -103,39 +103,89 @@ RSpec.describe ProjectPolicy do
end
context 'creating_merge_request_in' do
- context 'when project is public' do
- let(:project) { public_project }
+ context 'when the current_user can download_code' do
+ before do
+ expect(subject).to receive(:allowed?).with(:download_code).and_return(true)
+ allow(subject).to receive(:allowed?).with(any_args).and_call_original
+ end
- context 'when the current_user is guest' do
- let(:current_user) { guest }
+ context 'when project is public' do
+ let(:project) { public_project }
+
+ context 'when the current_user is guest' do
+ let(:current_user) { guest }
- it { is_expected.to be_allowed(:create_merge_request_in) }
+ it { is_expected.to be_allowed(:create_merge_request_in) }
+ end
end
- end
- context 'when project is internal' do
- let(:project) { internal_project }
+ context 'when project is internal' do
+ let(:project) { internal_project }
- context 'when the current_user is guest' do
- let(:current_user) { guest }
+ context 'when the current_user is guest' do
+ let(:current_user) { guest }
- it { is_expected.to be_allowed(:create_merge_request_in) }
+ it { is_expected.to be_allowed(:create_merge_request_in) }
+ end
+ end
+
+ context 'when project is private' do
+ let(:project) { private_project }
+
+ context 'when the current_user is guest' do
+ let(:current_user) { guest }
+
+ it { is_expected.not_to be_allowed(:create_merge_request_in) }
+ end
+
+ context 'when the current_user is reporter or above' do
+ let(:current_user) { reporter }
+
+ it { is_expected.to be_allowed(:create_merge_request_in) }
+ end
end
end
- context 'when project is private' do
- let(:project) { private_project }
+ context 'when the current_user can not download code' do
+ before do
+ expect(subject).to receive(:allowed?).with(:download_code).and_return(false)
+ allow(subject).to receive(:allowed?).with(any_args).and_call_original
+ end
- context 'when the current_user is guest' do
- let(:current_user) { guest }
+ context 'when project is public' do
+ let(:project) { public_project }
+
+ context 'when the current_user is guest' do
+ let(:current_user) { guest }
- it { is_expected.not_to be_allowed(:create_merge_request_in) }
+ it { is_expected.not_to be_allowed(:create_merge_request_in) }
+ end
end
- context 'when the current_user is reporter or above' do
- let(:current_user) { reporter }
+ context 'when project is internal' do
+ let(:project) { internal_project }
- it { is_expected.to be_allowed(:create_merge_request_in) }
+ context 'when the current_user is guest' do
+ let(:current_user) { guest }
+
+ it { is_expected.not_to be_allowed(:create_merge_request_in) }
+ end
+ end
+
+ context 'when project is private' do
+ let(:project) { private_project }
+
+ context 'when the current_user is guest' do
+ let(:current_user) { guest }
+
+ it { is_expected.not_to be_allowed(:create_merge_request_in) }
+ end
+
+ context 'when the current_user is reporter or above' do
+ let(:current_user) { reporter }
+
+ it { is_expected.not_to be_allowed(:create_merge_request_in) }
+ end
end
end
end