diff options
Diffstat (limited to 'spec/spec_helper.rb')
-rw-r--r-- | spec/spec_helper.rb | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 18bfe5a2be7..364c033900f 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -160,6 +160,25 @@ RSpec.configure do |config| allow(Gitlab::Git::KeepAround).to receive(:execute) Gitlab::ThreadMemoryCache.cache_backend.clear + + # Temporary patch to force admin mode to be active by default in tests when + # using the feature flag :user_mode_in_session, since this will require + # modifying a significant number of specs to test both states for admin + # mode enabled / disabled. + # + # See https://gitlab.com/gitlab-org/gitlab/issues/31511 + # See gitlab/spec/support/helpers/admin_mode_helpers.rb + # + # If it is required to have the real behaviour that an admin is signed in + # with normal user mode and needs to switch to admin mode, it is possible to + # mark such tests with the `do_not_mock_admin_mode` metadata tag, e.g: + # + # context 'some test with normal user mode', :do_not_mock_admin_mode do ... end + unless example.metadata[:do_not_mock_admin_mode] + allow_any_instance_of(Gitlab::Auth::CurrentUserMode).to receive(:admin_mode?) do |current_user_mode| + current_user_mode.send(:user)&.admin? + end + end end config.around(:example, :quarantine) do |example| |