From 5707f305f4b961e24369fcdaecf0b8ce1c34bad8 Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Thu, 26 Sep 2019 12:06:00 +0000 Subject: Add latest changes from gitlab-org/gitlab@master --- spec/spec_helper.rb | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'spec/spec_helper.rb') 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| -- cgit v1.2.3