diff options
-rw-r--r-- | app/controllers/admin/application_settings_controller.rb | 2 | ||||
-rw-r--r-- | app/models/application_setting.rb | 10 | ||||
-rw-r--r-- | config/initializers/8_application_settings.rb | 11 | ||||
-rw-r--r-- | lib/gitlab/current_settings.rb | 21 |
4 files changed, 24 insertions, 20 deletions
diff --git a/app/controllers/admin/application_settings_controller.rb b/app/controllers/admin/application_settings_controller.rb index 39ca0b4feba..5116f1f177a 100644 --- a/app/controllers/admin/application_settings_controller.rb +++ b/app/controllers/admin/application_settings_controller.rb @@ -16,7 +16,7 @@ class Admin::ApplicationSettingsController < Admin::ApplicationController private def set_application_setting - @application_setting = ApplicationSetting.last + @application_setting = ApplicationSetting.current end def application_setting_params diff --git a/app/models/application_setting.rb b/app/models/application_setting.rb index 4b885461cbb..47fa6f1071c 100644 --- a/app/models/application_setting.rb +++ b/app/models/application_setting.rb @@ -2,4 +2,14 @@ class ApplicationSetting < ActiveRecord::Base def self.current ApplicationSetting.last end + + def self.create_from_defaults + create( + default_projects_limit: Settings.gitlab['default_projects_limit'], + signup_enabled: Settings.gitlab['signup_enabled'], + signin_enabled: Settings.gitlab['signin_enabled'], + gravatar_enabled: Settings.gravatar['enabled'], + sign_in_text: Settings.extra['sign_in_text'], + ) + end end diff --git a/config/initializers/8_application_settings.rb b/config/initializers/8_application_settings.rb deleted file mode 100644 index 6f1dec7de09..00000000000 --- a/config/initializers/8_application_settings.rb +++ /dev/null @@ -1,11 +0,0 @@ -if ActiveRecord::Base.connection.table_exists?('application_settings') - unless ApplicationSetting.any? - ApplicationSetting.create( - default_projects_limit: Settings.gitlab['default_projects_limit'], - signup_enabled: Settings.gitlab['signup_enabled'], - signin_enabled: Settings.gitlab['signin_enabled'], - gravatar_enabled: Settings.gravatar['enabled'], - sign_in_text: Settings.extra['sign_in_text'], - ) - end -end diff --git a/lib/gitlab/current_settings.rb b/lib/gitlab/current_settings.rb index 60efc70aa40..f3b9dcacdee 100644 --- a/lib/gitlab/current_settings.rb +++ b/lib/gitlab/current_settings.rb @@ -2,16 +2,21 @@ module Gitlab module CurrentSettings def current_application_settings if ActiveRecord::Base.connection.table_exists?('application_settings') - ApplicationSetting.current + ApplicationSetting.current || + ApplicationSetting.create_from_defaults else - OpenStruct.new( - default_projects_limit: Settings.gitlab['default_projects_limit'], - signup_enabled: Settings.gitlab['signup_enabled'], - signin_enabled: Settings.gitlab['signin_enabled'], - gravatar_enabled: Settings.gravatar['enabled'], - sign_in_text: Settings.extra['sign_in_text'], - ) + fake_application_settings end end + + def fake_application_settings + OpenStruct.new( + default_projects_limit: Settings.gitlab['default_projects_limit'], + signup_enabled: Settings.gitlab['signup_enabled'], + signin_enabled: Settings.gitlab['signin_enabled'], + gravatar_enabled: Settings.gravatar['enabled'], + sign_in_text: Settings.extra['sign_in_text'], + ) + end end end |