summaryrefslogtreecommitdiff
path: root/spec/support/helpers/stub_configuration.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-12-20 14:22:11 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2022-12-20 14:22:11 +0000
commit0c872e02b2c822e3397515ec324051ff540f0cd5 (patch)
treece2fb6ce7030e4dad0f4118d21ab6453e5938cdd /spec/support/helpers/stub_configuration.rb
parentf7e05a6853b12f02911494c4b3fe53d9540d74fc (diff)
downloadgitlab-ce-0c872e02b2c822e3397515ec324051ff540f0cd5.tar.gz
Add latest changes from gitlab-org/gitlab@15-7-stable-eev15.7.0-rc42
Diffstat (limited to 'spec/support/helpers/stub_configuration.rb')
-rw-r--r--spec/support/helpers/stub_configuration.rb11
1 files changed, 11 insertions, 0 deletions
diff --git a/spec/support/helpers/stub_configuration.rb b/spec/support/helpers/stub_configuration.rb
index 24c768258a1..4ca8f26be9e 100644
--- a/spec/support/helpers/stub_configuration.rb
+++ b/spec/support/helpers/stub_configuration.rb
@@ -20,6 +20,17 @@ module StubConfiguration
allow_any_instance_of(ApplicationSetting).to receive(:cached_html_up_to_date?).and_return(false)
end
+ # For enums with `_prefix: true`, this allows us to stub the application setting properly
+ def stub_application_setting_enum(setting, value)
+ stub_application_setting(setting.to_sym => value)
+
+ ApplicationSetting.send(setting.pluralize.to_sym).each_key do |key|
+ stub_application_setting("#{setting}_#{key}".to_sym => key == value)
+ end
+
+ Gitlab::CurrentSettings.send(setting)
+ end
+
def stub_not_protect_default_branch
stub_application_setting(
default_branch_protection: Gitlab::Access::PROTECTION_NONE)