diff --git a/app/models/locale_site_setting.rb b/app/models/locale_site_setting.rb index fa624f8e3..1c3ae78ba 100644 --- a/app/models/locale_site_setting.rb +++ b/app/models/locale_site_setting.rb @@ -4,7 +4,7 @@ class LocaleSiteSetting supported_locales.include?(val) end - def self.all_values + def self.values supported_locales end diff --git a/app/models/s3_region_site_setting.rb b/app/models/s3_region_site_setting.rb index 8239b32ea..2b66348f5 100644 --- a/app/models/s3_region_site_setting.rb +++ b/app/models/s3_region_site_setting.rb @@ -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 \ No newline at end of file +end diff --git a/docs/INSTALL-ubuntu.md b/docs/INSTALL-ubuntu.md index eabf47bb9..f893e5459 100644 --- a/docs/INSTALL-ubuntu.md +++ b/docs/INSTALL-ubuntu.md @@ -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 diff --git a/lib/site_setting_extension.rb b/lib/site_setting_extension.rb index 05c8234fd..d63a8745a 100644 --- a/lib/site_setting_extension.rb +++ b/lib/site_setting_extension.rb @@ -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 diff --git a/spec/components/site_setting_extenstion_spec.rb b/spec/components/site_setting_extenstion_spec.rb index 37eaf068b..d84a0b012 100644 --- a/spec/components/site_setting_extenstion_spec.rb +++ b/spec/components/site_setting_extenstion_spec.rb @@ -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 diff --git a/spec/models/locale_site_setting_spec.rb b/spec/models/locale_site_setting_spec.rb index c7114fb98..b623a4502 100644 --- a/spec/models/locale_site_setting_spec.rb +++ b/spec/models/locale_site_setting_spec.rb @@ -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 diff --git a/spec/models/s3_region_site_setting_spec.rb b/spec/models/s3_region_site_setting_spec.rb index a7c5dc7ac..f0bb5421c 100644 --- a/spec/models/s3_region_site_setting_spec.rb +++ b/spec/models/s3_region_site_setting_spec.rb @@ -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 \ No newline at end of file +end