Merge branch 'mk-setup-settings-properly' into 'master'
Setup settings properly See merge request !13645
This commit is contained in:
commit
934342de78
2 changed files with 34 additions and 1 deletions
|
@ -139,6 +139,8 @@ if Settings.ldap['enabled'] || Rails.env.test?
|
|||
end
|
||||
|
||||
Settings.ldap['servers'].each do |key, server|
|
||||
server = Settingslogic.new(server)
|
||||
|
||||
server['label'] ||= 'LDAP'
|
||||
server['timeout'] ||= 10.seconds
|
||||
server['block_auto_created_users'] = false if server['block_auto_created_users'].nil?
|
||||
|
@ -165,6 +167,8 @@ if Settings.ldap['enabled'] || Rails.env.test?
|
|||
MSG
|
||||
Rails.logger.warn(message)
|
||||
end
|
||||
|
||||
Settings.ldap['servers'][key] = server
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -436,7 +440,9 @@ unless Settings.repositories.storages['default']
|
|||
Settings.repositories.storages['default']['path'] ||= Settings.gitlab['user_home'] + '/repositories/'
|
||||
end
|
||||
|
||||
Settings.repositories.storages.values.each do |storage|
|
||||
Settings.repositories.storages.each do |key, storage|
|
||||
storage = Settingslogic.new(storage)
|
||||
|
||||
# Expand relative paths
|
||||
storage['path'] = Settings.absolute(storage['path'])
|
||||
# Set failure defaults
|
||||
|
@ -450,6 +456,8 @@ Settings.repositories.storages.values.each do |storage|
|
|||
storage['failure_reset_time'] = storage['failure_reset_time'].to_i
|
||||
# We might want to have a timeout shorter than 1 second.
|
||||
storage['storage_timeout'] = storage['storage_timeout'].to_f
|
||||
|
||||
Settings.repositories.storages[key] = storage
|
||||
end
|
||||
|
||||
#
|
||||
|
|
|
@ -2,6 +2,22 @@ require 'spec_helper'
|
|||
require_relative '../../config/initializers/1_settings'
|
||||
|
||||
describe Settings do
|
||||
describe '#ldap' do
|
||||
it 'can be accessed with dot syntax all the way down' do
|
||||
expect(Gitlab.config.ldap.servers.main.label).to eq('ldap')
|
||||
end
|
||||
|
||||
# Specifically trying to cause this error discovered in EE when removing the
|
||||
# reassignment of each server element with Settingslogic.
|
||||
#
|
||||
# `undefined method `label' for #<Hash:0x007fbd18b59c08>`
|
||||
#
|
||||
it 'can be accessed in a very specific way that breaks without reassigning each element with Settingslogic' do
|
||||
server_settings = Gitlab.config.ldap.servers['main']
|
||||
expect(server_settings.label).to eq('ldap')
|
||||
end
|
||||
end
|
||||
|
||||
describe '#repositories' do
|
||||
it 'assigns the default failure attributes' do
|
||||
repository_settings = Gitlab.config.repositories.storages['broken']
|
||||
|
@ -11,6 +27,15 @@ describe Settings do
|
|||
expect(repository_settings['failure_reset_time']).to eq(1800)
|
||||
expect(repository_settings['storage_timeout']).to eq(5)
|
||||
end
|
||||
|
||||
it 'can be accessed with dot syntax all the way down' do
|
||||
expect(Gitlab.config.repositories.storages.broken.failure_count_threshold).to eq(10)
|
||||
end
|
||||
|
||||
it 'can be accessed in a very specific way that breaks without reassigning each element with Settingslogic' do
|
||||
storage_settings = Gitlab.config.repositories.storages['broken']
|
||||
expect(storage_settings.failure_count_threshold).to eq(10)
|
||||
end
|
||||
end
|
||||
|
||||
describe '#host_without_www' do
|
||||
|
|
Loading…
Reference in a new issue