Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarin Jankovski <maxlazio@gmail.com>2015-09-01 13:45:14 +0300
committerMarin Jankovski <maxlazio@gmail.com>2015-09-01 18:49:16 +0300
commit3a8773fb2f86757ce0a061ef6476b7d91bcb6259 (patch)
treec202fa2f0edd5828b7daf0d50d76c85a889c8643 /lib/gitlab
parentaa1c32145914c9645818bf2b4a5cc0701bc321f2 (diff)
Added USE_DB env var to allow loading fake settings without db running.
Diffstat (limited to 'lib/gitlab')
-rw-r--r--lib/gitlab/current_settings.rb14
1 files changed, 13 insertions, 1 deletions
diff --git a/lib/gitlab/current_settings.rb b/lib/gitlab/current_settings.rb
index 7ad3ed8728f..0ea1b6a2f6f 100644
--- a/lib/gitlab/current_settings.rb
+++ b/lib/gitlab/current_settings.rb
@@ -4,7 +4,7 @@ module Gitlab
key = :current_application_settings
RequestStore.store[key] ||= begin
- if ActiveRecord::Base.connection.active? && ActiveRecord::Base.connection.table_exists?('application_settings')
+ if connect_to_db?
ApplicationSetting.current || ApplicationSetting.create_from_defaults
else
fake_application_settings
@@ -26,5 +26,17 @@ module Gitlab
import_sources: Settings.gitlab['import_sources']
)
end
+
+ private
+
+ def connect_to_db?
+ use_db = if ENV['USE_DB'] == "false"
+ false
+ else
+ true
+ end
+
+ use_db && ActiveRecord::Base.connection.active? && ActiveRecord::Base.connection.table_exists?('application_settings')
+ end
end
end