Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-03-03 03:20:18 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-03-03 03:20:18 +0300
commit475d5a7a176dcb87bd1fb8d55883ad2b3b2a7955 (patch)
tree93a6467c8d82d26468ce3dcebef5a7838c5a974b /spec/validators
parentbd091da6d5cb036cf3c58d4ba5671f931c8381e1 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/validators')
-rw-r--r--spec/validators/color_validator_spec.rb23
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