mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-27 17:46:05 -05:00
values is a much more consistent name than all_values ... we use {}.values not {}.all_values
also fixes random ordering of tests failure in site settings
This commit is contained in:
parent
22d6f6784c
commit
ea932b74e7
7 changed files with 16 additions and 12 deletions
|
@ -4,7 +4,7 @@ class LocaleSiteSetting
|
|||
supported_locales.include?(val)
|
||||
end
|
||||
|
||||
def self.all_values
|
||||
def self.values
|
||||
supported_locales
|
||||
end
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
class S3RegionSiteSetting
|
||||
def self.valid_value?(val)
|
||||
all_values.include? val
|
||||
values.include? val
|
||||
end
|
||||
|
||||
def self.all_values
|
||||
@all_values ||= ['', 'us-east-1', 'us-west-1', 'us-west-2', 'eu-west-1', 'ap-southeast-1', 'ap-southeast-2', 'ap-northeast-1', 'sa-east-1'].sort
|
||||
def self.values
|
||||
@values ||= ['', 'us-east-1', 'us-west-1', 'us-west-2', 'eu-west-1', 'ap-southeast-1', 'ap-southeast-2', 'ap-northeast-1', 'sa-east-1'].sort
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -249,7 +249,7 @@ Not english? Set the default language as appropriate:
|
|||
SiteSetting.default_locale = 'fr'
|
||||
|
||||
# Not sure if your locale is supported? Check at the rails console:
|
||||
LocaleSiteSetting.all_values
|
||||
LocaleSiteSetting.values
|
||||
=> ["cs", "da", "de", "en", "es", "fr", "id", "it", "nb_NO", "nl", "pseudo", "pt", "ru", "sv", "zh_CN", "zh_TW"]
|
||||
|
||||
## nginx setup
|
||||
|
|
|
@ -80,7 +80,7 @@ module SiteSettingExtension
|
|||
description: description(s),
|
||||
default: v,
|
||||
type: type.to_s,
|
||||
value: value.to_s}.merge( type == :enum ? {valid_values: enum_class(s).all_values} : {})
|
||||
value: value.to_s}.merge( type == :enum ? {valid_values: enum_class(s).values} : {})
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -142,6 +142,10 @@ describe SiteSettingExtension do
|
|||
expect(settings.test_enum).to eq('en')
|
||||
end
|
||||
|
||||
it 'should not hose all_settings' do
|
||||
settings.all_settings.detect {|s| s[:setting] == :test_enum }.should be_present
|
||||
end
|
||||
|
||||
context 'when overridden' do
|
||||
|
||||
it 'stores valid values' do
|
||||
|
|
|
@ -12,9 +12,9 @@ describe LocaleSiteSetting do
|
|||
end
|
||||
end
|
||||
|
||||
describe 'all_values' do
|
||||
describe 'values' do
|
||||
it 'returns all the locales that we have translations for' do
|
||||
expect(LocaleSiteSetting.all_values.sort).to eq(Dir.glob( File.join(Rails.root, 'config', 'locales', 'client.*.yml') ).map {|x| x.split('.')[-2]}.sort)
|
||||
expect(LocaleSiteSetting.values.sort).to eq(Dir.glob( File.join(Rails.root, 'config', 'locales', 'client.*.yml') ).map {|x| x.split('.')[-2]}.sort)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -12,10 +12,10 @@ describe S3RegionSiteSetting do
|
|||
end
|
||||
end
|
||||
|
||||
describe 'all_values' do
|
||||
describe 'values' do
|
||||
it 'returns all the S3 regions and blank' do
|
||||
expect(S3RegionSiteSetting.all_values.sort).to eq(['', 'us-east-1', 'us-west-1', 'us-west-2', 'eu-west-1', 'ap-southeast-1', 'ap-southeast-2', 'ap-northeast-1', 'sa-east-1'].sort)
|
||||
expect(S3RegionSiteSetting.values.sort).to eq(['', 'us-east-1', 'us-west-1', 'us-west-2', 'eu-west-1', 'ap-southeast-1', 'ap-southeast-2', 'ap-northeast-1', 'sa-east-1'].sort)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue