diff options
author | Andrei Gliga <otzy_007@yahoo.com> | 2016-05-04 15:57:00 +0300 |
---|---|---|
committer | Andrei Gliga <otzy_007@yahoo.com> | 2016-05-12 13:44:46 +0300 |
commit | 47ee5125e881694b7713f187b48589a2f4bbd747 (patch) | |
tree | 98cc17644946c4060244a0085d095daf1182a036 | |
parent | 7c7c5b7e40ff4fed64a9f62beed027064c292eaf (diff) | |
download | gitlab-ce-47ee5125e881694b7713f187b48589a2f4bbd747.tar.gz |
validate disabled_oauth_sign_in_sources in ApplicationSe
-rw-r--r-- | app/models/application_setting.rb | 10 | ||||
-rw-r--r-- | spec/models/application_setting_spec.rb | 3 |
2 files changed, 13 insertions, 0 deletions
diff --git a/app/models/application_setting.rb b/app/models/application_setting.rb index a48deccb029..d565dbc71d0 100644 --- a/app/models/application_setting.rb +++ b/app/models/application_setting.rb @@ -119,6 +119,16 @@ class ApplicationSetting < ActiveRecord::Base end end + validates_each :disabled_oauth_sign_in_sources do |record, attr, value| + unless value.nil? + value.each do |source| + unless Devise.omniauth_providers.include?(source.to_sym) + record.errors.add(attr, "'#{source}' is not an ouath sign-in source") + end + end + end + end + before_save :ensure_runners_registration_token after_commit do diff --git a/spec/models/application_setting_spec.rb b/spec/models/application_setting_spec.rb index 1ce22feed5c..fb3ea491df7 100644 --- a/spec/models/application_setting_spec.rb +++ b/spec/models/application_setting_spec.rb @@ -20,6 +20,9 @@ describe ApplicationSetting, models: true do it { is_expected.to allow_value(https).for(:after_sign_out_path) } it { is_expected.not_to allow_value(ftp).for(:after_sign_out_path) } + it { is_expected.to allow_value([:github]).for(:disabled_oauth_sign_in_sources) } + it { is_expected.not_to allow_value([:test]).for(:disabled_oauth_sign_in_sources) } + it { is_expected.to validate_presence_of(:max_attachment_size) } it do |