More review comments

This commit is contained in:
Nick Thomas 2017-08-30 21:20:00 +01:00
parent eb05bdc6f5
commit 29b40db589
5 changed files with 13 additions and 3 deletions

View File

@ -3,7 +3,6 @@ module FormHelper
return unless model.errors.any?
pluralized = 'error'.pluralize(model.errors.count)
headline = "The #{type} contains the following #{pluralized}:"
content_tag(:div, class: 'alert alert-danger', id: 'error_explanation') do

View File

@ -155,6 +155,8 @@ class ApplicationSetting < ActiveRecord::Base
validates :"#{type}_key_restriction", presence: true, key_restriction: { type: type }
end
validates :allowed_key_types, presence: true
validates_each :restricted_visibility_levels do |record, attr, value|
value&.each do |level|
unless Gitlab::VisibilityLevel.options.value?(level)

View File

@ -3,8 +3,8 @@
- if key.valid?
= icon 'key', class: 'settings-list-icon hidden-xs'
- else
= icon 'exclamation-triangle', class: 'settings-list-icon hidden-xs',
title: 'The key is disabled because it is invalid'
= icon 'exclamation-triangle', class: 'settings-list-icon hidden-xs has-tooltip',
title: key.errors.full_messages.join(', ')
.key-list-item-info

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 67 KiB

View File

@ -77,6 +77,15 @@ describe ApplicationSetting do
expect(described_class::SUPPORTED_KEY_TYPES).to contain_exactly(:rsa, :dsa, :ecdsa, :ed25519)
end
it 'does not allow all key types to be disabled' do
described_class::SUPPORTED_KEY_TYPES.each do |type|
setting["#{type}_key_restriction"] = described_class::FORBIDDEN_KEY_VALUE
end
expect(setting).not_to be_valid
expect(setting.errors.messages).to have_key(:allowed_key_types)
end
where(:type) do
described_class::SUPPORTED_KEY_TYPES
end