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:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-11-06 21:06:29 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2019-11-06 21:06:29 +0300
commitbcdcff749598f4275f7c250c07cbfe632cfe7fdb (patch)
treefa3f6e54632837f21319794dbd9136e3de3a76ba /spec/policies
parent5277f8e69e935eabd3bf8c5e7833471b5bfad1d9 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/policies')
-rw-r--r--spec/policies/base_policy_spec.rb41
1 files changed, 38 insertions, 3 deletions
diff --git a/spec/policies/base_policy_spec.rb b/spec/policies/base_policy_spec.rb
index 9e59d35b1bb..81aee4cfcac 100644
--- a/spec/policies/base_policy_spec.rb
+++ b/spec/policies/base_policy_spec.rb
@@ -2,8 +2,9 @@
require 'spec_helper'
-describe BasePolicy do
+describe BasePolicy, :do_not_mock_admin_mode do
include ExternalAuthorizationServiceHelpers
+ include AdminModeHelper
describe '.class_for' do
it 'detects policy class based on the subject ancestors' do
@@ -36,8 +37,42 @@ describe BasePolicy do
it { is_expected.not_to be_allowed(:read_cross_project) }
- it 'allows admins' do
- expect(described_class.new(build(:admin), nil)).to be_allowed(:read_cross_project)
+ context 'for admins' do
+ let(:current_user) { build(:admin) }
+
+ subject { described_class.new(current_user, nil) }
+
+ it 'allowed when in admin mode' do
+ enable_admin_mode!(current_user)
+
+ is_expected.to be_allowed(:read_cross_project)
+ end
+
+ it 'prevented when not in admin mode' do
+ is_expected.not_to be_allowed(:read_cross_project)
+ end
+ end
+ end
+ end
+
+ describe 'full private access' do
+ let(:current_user) { create(:user) }
+
+ subject { described_class.new(current_user, nil) }
+
+ it { is_expected.not_to be_allowed(:read_all_resources) }
+
+ context 'for admins' do
+ let(:current_user) { build(:admin) }
+
+ it 'allowed when in admin mode' do
+ enable_admin_mode!(current_user)
+
+ is_expected.to be_allowed(:read_all_resources)
+ end
+
+ it 'prevented when not in admin mode' do
+ is_expected.not_to be_allowed(:read_all_resources)
end
end
end