summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Speicher <robert@gitlab.com>2018-09-10 22:38:12 +0000
committerRobert Speicher <robert@gitlab.com>2018-09-10 22:38:12 +0000
commit93875aad4a5f5cecb94c63b08ea2a255518a5af5 (patch)
tree4de2056289f575107240ddc11282be8d23f3ccfe
parent79e47dd28380cde8c58d37a21daf24b1c1cf65c2 (diff)
parent855b23836168d1621a3dcb748e1a849d8833a7c3 (diff)
downloadgitlab-ce-93875aad4a5f5cecb94c63b08ea2a255518a5af5.tar.gz
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
-rw-r--r--lib/gitlab/current_settings.rb4
-rw-r--r--lib/gitlab/fake_application_settings.rb4
-rw-r--r--spec/spec_helper.rb4
3 files changed, 12 insertions, 0 deletions
diff --git a/lib/gitlab/current_settings.rb b/lib/gitlab/current_settings.rb
index 9147ef401da..c9dbd2d2e5f 100644
--- a/lib/gitlab/current_settings.rb
+++ b/lib/gitlab/current_settings.rb
@@ -13,6 +13,10 @@ module Gitlab
Gitlab::FakeApplicationSettings.new(::ApplicationSetting.defaults.merge(attributes || {}))
end
+ def clear_in_memory_application_settings!
+ @in_memory_application_settings = nil
+ end
+
def method_missing(name, *args, &block)
current_application_settings.send(name, *args, &block) # rubocop:disable GitlabSecurity/PublicSend
end
diff --git a/lib/gitlab/fake_application_settings.rb b/lib/gitlab/fake_application_settings.rb
index bb14a8cd9e7..753160cc562 100644
--- a/lib/gitlab/fake_application_settings.rb
+++ b/lib/gitlab/fake_application_settings.rb
@@ -11,6 +11,10 @@ module Gitlab
FakeApplicationSettings.define_predicate_methods(options)
end
+ def pick_repository_storage
+ repository_storages.sample
+ end
+
# Mimic ActiveRecord predicate methods for boolean values
def self.define_predicate_methods(options)
options.each do |key, value|
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index c4bb1c13f2e..d1337325973 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -135,6 +135,10 @@ RSpec.configure do |config|
Fog.unmock! if Fog.mock?
end
+ config.after(:example) do
+ Gitlab::CurrentSettings.clear_in_memory_application_settings!
+ end
+
config.before(:example, :mailer) do
reset_delivered_emails!
end