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.rb36
1 files changed, 21 insertions, 15 deletions
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 62fdc039b5e..bd504f1553b 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -3,6 +3,7 @@ SimpleCovEnv.start!
ENV["RAILS_ENV"] = 'test'
ENV["IN_MEMORY_APPLICATION_SETTINGS"] = 'true'
+ENV["RSPEC_ALLOW_INVALID_URLS"] = 'true'
require File.expand_path('../config/environment', __dir__)
require 'rspec/rails'
@@ -47,7 +48,10 @@ Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f }
quality_level = Quality::TestLevel.new
RSpec.configure do |config|
- config.use_transactional_fixtures = false
+ config.filter_run focus: true
+ config.run_all_when_everything_filtered = true
+
+ config.use_transactional_fixtures = true
config.use_instantiated_fixtures = false
config.fixture_path = Rails.root
@@ -103,6 +107,8 @@ RSpec.configure do |config|
config.include RedisHelpers
config.include Rails.application.routes.url_helpers, type: :routing
config.include PolicyHelpers, type: :policy
+ config.include MemoryUsageHelper
+ config.include ExpectRequestWithStatus, type: :request
if ENV['CI']
# This includes the first try, i.e. tests will be run 4 times before failing.
@@ -133,6 +139,8 @@ RSpec.configure do |config|
allow(Feature).to receive(:enabled?).with(flag).and_return(enabled)
end
+ allow(Gitlab::GitalyClient).to receive(:can_use_disk?).and_return(enabled)
+
# 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)
@@ -143,9 +151,9 @@ RSpec.configure do |config|
Gitlab::ThreadMemoryCache.cache_backend.clear
end
- config.around(:example, :quarantine) do
+ config.around(:example, :quarantine) do |example|
# Skip tests in quarantine unless we explicitly focus on them.
- skip('In quarantine') unless config.inclusion_filter[:quarantine]
+ example.run if config.inclusion_filter[:quarantine]
end
config.before(:example, :request_store) do
@@ -254,18 +262,6 @@ RSpec.configure do |config|
Gitlab::CurrentSettings.clear_in_memory_application_settings!
end
- config.around(:each, :nested_groups) do |example|
- example.run if Group.supports_nested_objects?
- end
-
- config.around(:each, :postgresql) do |example|
- example.run if Gitlab::Database.postgresql?
- end
-
- config.around(:each, :mysql) do |example|
- example.run if Gitlab::Database.mysql?
- end
-
# This makes sure the `ApplicationController#can?` method is stubbed with the
# original implementation for all view specs.
config.before(:each, type: :view) do
@@ -289,6 +285,16 @@ RSpec.configure do |config|
config.before(:each, :https_pages_disabled) do |_|
allow(Gitlab.config.pages).to receive(:external_https).and_return(false)
end
+
+ # We can't use an `around` hook here because the wrapping transaction
+ # is not yet opened at the time that is triggered
+ config.prepend_before do
+ Gitlab::Database.set_open_transactions_baseline
+ end
+
+ config.append_after do
+ Gitlab::Database.reset_open_transactions_baseline
+ end
end
# add simpler way to match asset paths containing digest strings