summaryrefslogtreecommitdiff
path: root/spec/spec_helper.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/spec_helper.rb')
-rw-r--r--spec/spec_helper.rb52
1 files changed, 21 insertions, 31 deletions
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index fe03621b9bf..80dfa20a2f1 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -8,10 +8,12 @@ ENV["IN_MEMORY_APPLICATION_SETTINGS"] = 'true'
ENV["RSPEC_ALLOW_INVALID_URLS"] = 'true'
require File.expand_path('../config/environment', __dir__)
+
+require 'rspec/mocks'
require 'rspec/rails'
-require 'shoulda/matchers'
require 'rspec/retry'
require 'rspec-parameterized'
+require 'shoulda/matchers'
require 'test_prof/recipes/rspec/let_it_be'
rspec_profiling_is_configured =
@@ -173,21 +175,19 @@ RSpec.configure do |config|
# Enable all features by default for testing
allow(Feature).to receive(:enabled?) { true }
- enabled = example.metadata[:enable_rugged].present?
+ enable_rugged = example.metadata[:enable_rugged].present?
# Disable Rugged features by default
Gitlab::Git::RuggedImpl::Repository::FEATURE_FLAGS.each do |flag|
- allow(Feature).to receive(:enabled?).with(flag).and_return(enabled)
+ stub_feature_flags(flag => enable_rugged)
end
- allow(Gitlab::GitalyClient).to receive(:can_use_disk?).and_return(enabled)
+ allow(Gitlab::GitalyClient).to receive(:can_use_disk?).and_return(enable_rugged)
# The following can be removed when we remove the staged rollout strategy
# and we can just enable it using instance wide settings
# (ie. ApplicationSetting#auto_devops_enabled)
- allow(Feature).to receive(:enabled?)
- .with(:force_autodevops_on_by_default, anything)
- .and_return(false)
+ stub_feature_flags(force_autodevops_on_by_default: false)
# Enable Marginalia feature for all specs in the test suite.
allow(Gitlab::Marginalia).to receive(:cached_feature_enabled?).and_return(true)
@@ -196,11 +196,11 @@ RSpec.configure do |config|
# is feature-complete and can be made default in place
# of older sidebar.
# See https://gitlab.com/groups/gitlab-org/-/epics/1863
+ stub_feature_flags(vue_issuable_sidebar: false)
+ stub_feature_flags(vue_issuable_epic_sidebar: false)
+
allow(Feature).to receive(:enabled?)
- .with(:vue_issuable_sidebar, anything)
- .and_return(false)
- allow(Feature).to receive(:enabled?)
- .with(:vue_issuable_epic_sidebar, anything)
+ .with(/\Apromo_\w+\z/, default_enabled: false)
.and_return(false)
# Stub these calls due to being expensive operations
@@ -209,9 +209,7 @@ RSpec.configure do |config|
# expect(Gitlab::Git::KeepAround).to receive(:execute).and_call_original
allow(Gitlab::Git::KeepAround).to receive(:execute)
- [Gitlab::ThreadMemoryCache, Gitlab::ProcessMemoryCache].each do |cache|
- cache.cache_backend.clear
- end
+ Gitlab::ProcessMemoryCache.cache_backend.clear
Sidekiq::Worker.clear_all
@@ -235,26 +233,25 @@ RSpec.configure do |config|
./ee/spec/features
./ee/spec/finders
./ee/spec/lib
- ./ee/spec/models
- ./ee/spec/policies
./ee/spec/requests/admin
./ee/spec/serializers
./ee/spec/services
./ee/spec/support/protected_tags
- ./ee/spec/support/shared_examples
+ ./ee/spec/support/shared_examples/features
+ ./ee/spec/support/shared_examples/finders/geo
+ ./ee/spec/support/shared_examples/graphql/geo
+ ./ee/spec/support/shared_examples/services
./spec/features
./spec/finders
./spec/frontend
./spec/helpers
./spec/lib
- ./spec/models
- ./spec/policies
./spec/requests
./spec/serializers
./spec/services
- ./spec/support/cycle_analytics_helpers
./spec/support/protected_tags
- ./spec/support/shared_examples
+ ./spec/support/shared_examples/features
+ ./spec/support/shared_examples/requests
./spec/views
./spec/workers
)
@@ -286,12 +283,7 @@ RSpec.configure do |config|
end
config.around(:example, :request_store) do |example|
- RequestStore.begin!
-
- example.run
-
- RequestStore.end!
- RequestStore.clear!
+ Gitlab::WithRequestStore.with_request_store { example.run }
end
config.around do |example|
@@ -305,12 +297,10 @@ RSpec.configure do |config|
Gitlab::SidekiqMiddleware.server_configurator(
metrics: false, # The metrics don't go anywhere in tests
arguments_logger: false, # We're not logging the regular messages for inline jobs
- memory_killer: false, # This is not a thing we want to do inline in tests
- # Don't enable this if the request store is active in the spec itself
- # This needs to run within the `request_store` around block defined above
- request_store: !RequestStore.active?
+ memory_killer: false # This is not a thing we want to do inline in tests
).call(chain)
chain.add DisableQueryLimit
+ chain.insert_after ::Gitlab::SidekiqMiddleware::RequestStoreMiddleware, IsolatedRequestStore
example.run
end