Commit 93875aad authored by Robert Speicher's avatar Robert Speicher

Merge branch '51268-clear-in-memory-application-settings-between-examples' into 'master'

Resolve "Changes in in-memory application settings in one spec can break another spec"

Closes #51268

See merge request gitlab-org/gitlab-ce!21638
parents 79e47dd2 855b2383
...@@ -13,6 +13,10 @@ module Gitlab ...@@ -13,6 +13,10 @@ module Gitlab
Gitlab::FakeApplicationSettings.new(::ApplicationSetting.defaults.merge(attributes || {})) Gitlab::FakeApplicationSettings.new(::ApplicationSetting.defaults.merge(attributes || {}))
end end
def clear_in_memory_application_settings!
@in_memory_application_settings = nil
end
def method_missing(name, *args, &block) def method_missing(name, *args, &block)
current_application_settings.send(name, *args, &block) # rubocop:disable GitlabSecurity/PublicSend current_application_settings.send(name, *args, &block) # rubocop:disable GitlabSecurity/PublicSend
end end
......
...@@ -11,6 +11,10 @@ module Gitlab ...@@ -11,6 +11,10 @@ module Gitlab
FakeApplicationSettings.define_predicate_methods(options) FakeApplicationSettings.define_predicate_methods(options)
end end
def pick_repository_storage
repository_storages.sample
end
# Mimic ActiveRecord predicate methods for boolean values # Mimic ActiveRecord predicate methods for boolean values
def self.define_predicate_methods(options) def self.define_predicate_methods(options)
options.each do |key, value| options.each do |key, value|
......
...@@ -135,6 +135,10 @@ RSpec.configure do |config| ...@@ -135,6 +135,10 @@ RSpec.configure do |config|
Fog.unmock! if Fog.mock? Fog.unmock! if Fog.mock?
end end
config.after(:example) do
Gitlab::CurrentSettings.clear_in_memory_application_settings!
end
config.before(:example, :mailer) do config.before(:example, :mailer) do
reset_delivered_emails! reset_delivered_emails!
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment