summaryrefslogtreecommitdiff
path: root/spec/spec_helper.rb
diff options
context:
space:
mode:
authorRobert Speicher <rspeicher@gmail.com>2021-01-20 13:34:23 -0600
committerRobert Speicher <rspeicher@gmail.com>2021-01-20 13:34:23 -0600
commit6438df3a1e0fb944485cebf07976160184697d72 (patch)
tree00b09bfd170e77ae9391b1a2f5a93ef6839f2597 /spec/spec_helper.rb
parent42bcd54d971da7ef2854b896a7b34f4ef8601067 (diff)
downloadgitlab-ce-6438df3a1e0fb944485cebf07976160184697d72.tar.gz
Add latest changes from gitlab-org/gitlab@13-8-stable-eev13.8.0-rc42
Diffstat (limited to 'spec/spec_helper.rb')
-rw-r--r--spec/spec_helper.rb42
1 files changed, 4 insertions, 38 deletions
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index c19c26f9a0b..9fac6c8e192 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -272,41 +272,6 @@ RSpec.configure do |config|
Sidekiq::Worker.clear_all
- # 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.
- #
- # This will only be applied to specs below dirs in `admin_mode_mock_dirs`
- #
- # See ongoing migration: https://gitlab.com/gitlab-org/gitlab/-/issues/31511
- #
- # Until the migration is finished, if it is required to have the real
- # behaviour in any of the mocked dirs specs 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 in mocked dir', :do_not_mock_admin_mode do ... end
- admin_mode_mock_dirs = %w(
- ./ee/spec/elastic_integration
- ./ee/spec/finders
- ./ee/spec/lib
- ./ee/spec/serializers
- ./ee/spec/support/shared_examples/finders/geo
- ./ee/spec/support/shared_examples/graphql/geo
- ./spec/finders
- ./spec/lib
- ./spec/serializers
- ./spec/support/shared_examples/lib/gitlab
- ./spec/workers
- )
-
- if !example.metadata[:do_not_mock_admin_mode] && example.metadata[:file_path].start_with?(*admin_mode_mock_dirs)
- allow_any_instance_of(Gitlab::Auth::CurrentUserMode).to receive(:admin_mode?) do |current_user_mode|
- current_user_mode.send(:user)&.admin?
- end
- end
-
# Administrators have to re-authenticate in order to access administrative
# functionality when feature flag :user_mode_in_session is active. Any spec
# that requires administrative access can use the tag :enable_admin_mode
@@ -314,6 +279,10 @@ RSpec.configure do |config|
#
# context 'some test that requires admin mode', :enable_admin_mode do ... end
#
+ # Some specs do get admin mode enabled automatically (e.g. `spec/controllers/admin`).
+ # In this case, specs that need to test both admin mode states can use the
+ # :do_not_mock_admin_mode tag to disable auto admin mode.
+ #
# See also spec/support/helpers/admin_mode_helpers.rb
if example.metadata[:enable_admin_mode] && !example.metadata[:do_not_mock_admin_mode]
allow_any_instance_of(Gitlab::Auth::CurrentUserMode).to receive(:admin_mode?) do |current_user_mode|
@@ -400,8 +369,5 @@ end
# Prevent Rugged from picking up local developer gitconfig.
Rugged::Settings['search_path_global'] = Rails.root.join('tmp/tests').to_s
-# Disable timestamp checks for invisible_captcha
-InvisibleCaptcha.timestamp_enabled = false
-
# Initialize FactoryDefault to use create_default helper
TestProf::FactoryDefault.init