diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-03-03 03:20:18 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-03-03 03:20:18 +0300 |
commit | 475d5a7a176dcb87bd1fb8d55883ad2b3b2a7955 (patch) | |
tree | 93a6467c8d82d26468ce3dcebef5a7838c5a974b /spec/validators/color_validator_spec.rb | |
parent | bd091da6d5cb036cf3c58d4ba5671f931c8381e1 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/validators/color_validator_spec.rb')
-rw-r--r-- | spec/validators/color_validator_spec.rb | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/spec/validators/color_validator_spec.rb b/spec/validators/color_validator_spec.rb index 27acbe5e89d..9c1339caffb 100644 --- a/spec/validators/color_validator_spec.rb +++ b/spec/validators/color_validator_spec.rb @@ -23,7 +23,12 @@ RSpec.describe ColorValidator do '#ffff' | false '#000111222' | false 'invalid' | false + 'red' | false '000' | false + nil | true # use presence to validate non-nil + '' | false + Time.current | false + ::Gitlab::Color.of(:red) | true end with_them do @@ -41,4 +46,22 @@ RSpec.describe ColorValidator do Timeout.timeout(5.seconds) { subject.valid? } end.not_to raise_error end + + context 'when color must be present' do + subject do + Class.new do + include ActiveModel::Model + include ActiveModel::Validations + attr_accessor :color + + validates :color, color: true, presence: true + end.new + end + + it 'rejects nil' do + subject.color = nil + + expect(subject).not_to be_valid + end + end end |