summaryrefslogtreecommitdiff
path: root/lib/gitlab/current_settings.rb
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzegorz@gitlab.com>2017-01-21 22:55:35 +0000
committerGrzegorz Bizon <grzegorz@gitlab.com>2017-01-21 22:55:35 +0000
commitbaeaa97ef49558a303b0bd7b6cc9ce4ccfc13d1d (patch)
treec009601bc21af2f88f0d246427d5fbe3db5e5bb2 /lib/gitlab/current_settings.rb
parentf6f52b43b59641f5e0c6f7aa47b1354ca3aeee32 (diff)
downloadgitlab-ce-baeaa97ef49558a303b0bd7b6cc9ce4ccfc13d1d.tar.gz
Revert "Merge branch 'dont-persist-application-settings-in-test-env' into 'master'"
This reverts merge request !8573
Diffstat (limited to 'lib/gitlab/current_settings.rb')
-rw-r--r--lib/gitlab/current_settings.rb44
1 files changed, 31 insertions, 13 deletions
diff --git a/lib/gitlab/current_settings.rb b/lib/gitlab/current_settings.rb
index c79e17b57ee..2ff27e46d64 100644
--- a/lib/gitlab/current_settings.rb
+++ b/lib/gitlab/current_settings.rb
@@ -9,9 +9,7 @@ module Gitlab
end
def ensure_application_settings!
- return fake_application_settings unless connect_to_db?
-
- unless ENV['IN_MEMORY_APPLICATION_SETTINGS'] == 'true'
+ if connect_to_db?
begin
settings = ::ApplicationSetting.current
# In case Redis isn't running or the Redis UNIX socket file is not available
@@ -22,23 +20,43 @@ module Gitlab
settings ||= ::ApplicationSetting.create_from_defaults unless ActiveRecord::Migrator.needs_migration?
end
- settings || in_memory_application_settings
+ settings || fake_application_settings
end
def sidekiq_throttling_enabled?
current_application_settings.sidekiq_throttling_enabled?
end
- def in_memory_application_settings
- @in_memory_application_settings ||= ApplicationSetting.new(ApplicationSetting::DEFAULTS)
- # In case migrations the application_settings table is not created yet,
- # we fallback to a simple OpenStruct
- rescue ActiveRecord::StatementInvalid
- fake_application_settings
- end
-
def fake_application_settings
- OpenStruct.new(ApplicationSetting::DEFAULTS)
+ OpenStruct.new(
+ default_projects_limit: Settings.gitlab['default_projects_limit'],
+ default_branch_protection: Settings.gitlab['default_branch_protection'],
+ signup_enabled: Settings.gitlab['signup_enabled'],
+ signin_enabled: Settings.gitlab['signin_enabled'],
+ gravatar_enabled: Settings.gravatar['enabled'],
+ koding_enabled: false,
+ plantuml_enabled: false,
+ sign_in_text: nil,
+ after_sign_up_text: nil,
+ help_page_text: nil,
+ shared_runners_text: nil,
+ restricted_visibility_levels: Settings.gitlab['restricted_visibility_levels'],
+ max_attachment_size: Settings.gitlab['max_attachment_size'],
+ session_expire_delay: Settings.gitlab['session_expire_delay'],
+ default_project_visibility: Settings.gitlab.default_projects_features['visibility_level'],
+ default_snippet_visibility: Settings.gitlab.default_projects_features['visibility_level'],
+ domain_whitelist: Settings.gitlab['domain_whitelist'],
+ import_sources: %w[gitea github bitbucket gitlab google_code fogbugz git gitlab_project],
+ shared_runners_enabled: Settings.gitlab_ci['shared_runners_enabled'],
+ max_artifacts_size: Settings.artifacts['max_size'],
+ require_two_factor_authentication: false,
+ two_factor_grace_period: 48,
+ akismet_enabled: false,
+ repository_checks_enabled: true,
+ container_registry_token_expire_delay: 5,
+ user_default_external: false,
+ sidekiq_throttling_enabled: false,
+ )
end
private