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>2021-04-23 12:10:03 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-04-23 12:10:03 +0300
commit65f7976d0cd11d91a4c0945b2c63a1aa2f888b07 (patch)
tree07a0e774b12b29352ca6b3bd87b108879ebb00b9 /spec/validators
parent1165608bfd217a96e133487d6049a989a15789c4 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/validators')
-rw-r--r--spec/validators/addressable_url_validator_spec.rb12
-rw-r--r--spec/validators/array_members_validator_spec.rb4
-rw-r--r--spec/validators/devise_email_validator_spec.rb4
-rw-r--r--spec/validators/gitlab/utils/zoom_url_validator_spec.rb2
-rw-r--r--spec/validators/qualified_domain_array_validator_spec.rb8
5 files changed, 16 insertions, 14 deletions
diff --git a/spec/validators/addressable_url_validator_spec.rb b/spec/validators/addressable_url_validator_spec.rb
index 394ffc7bbea..ec3ee9aa500 100644
--- a/spec/validators/addressable_url_validator_spec.rb
+++ b/spec/validators/addressable_url_validator_spec.rb
@@ -19,18 +19,20 @@ RSpec.describe AddressableUrlValidator do
it 'returns error when url is nil' do
expect(validator.validate_each(badge, :link_url, nil)).to be_falsey
- expect(badge.errors.first[1]).to eq validator.options.fetch(:message)
+ expect(badge.errors.added?(:link_url, validator.options.fetch(:message))).to be true
end
it 'returns error when url is empty' do
expect(validator.validate_each(badge, :link_url, '')).to be_falsey
- expect(badge.errors.first[1]).to eq validator.options.fetch(:message)
+ expect(badge.errors.added?(:link_url, validator.options.fetch(:message))).to be true
end
it 'does not allow urls with CR or LF characters' do
aggregate_failures do
urls_with_CRLF.each do |url|
- expect(validator.validate_each(badge, :link_url, url)[0]).to eq 'is blocked: URI is invalid'
+ validator.validate_each(badge, :link_url, url)
+
+ expect(badge.errors.added?(:link_url, 'is blocked: URI is invalid')).to be true
end
end
end
@@ -113,7 +115,7 @@ RSpec.describe AddressableUrlValidator do
it 'does block nil url with provided error message' do
expect(validator.validate_each(badge, :link_url, nil)).to be_falsey
- expect(badge.errors.first[1]).to eq message
+ expect(badge.errors.added?(:link_url, message)).to be true
end
end
@@ -126,7 +128,7 @@ RSpec.describe AddressableUrlValidator do
subject
- expect(badge.errors.first[1]).to eq 'is not allowed due to: Only allowed schemes are http, https'
+ expect(badge.errors.added?(:link_url, 'is not allowed due to: Only allowed schemes are http, https')).to be true
end
end
diff --git a/spec/validators/array_members_validator_spec.rb b/spec/validators/array_members_validator_spec.rb
index ff8f0da7651..c6960925487 100644
--- a/spec/validators/array_members_validator_spec.rb
+++ b/spec/validators/array_members_validator_spec.rb
@@ -49,7 +49,7 @@ RSpec.describe ArrayMembersValidator do
object = test_class.new(children: [])
expect(object.valid?).to be_falsey
- expect(object.errors.messages).to eql(children: ['should be an array of children objects'])
+ expect(object.errors.messages).to eq(children: ['should be an array of children objects'])
end
end
@@ -62,7 +62,7 @@ RSpec.describe ArrayMembersValidator do
object = test_class.new(children: [])
expect(object.valid?).to be_falsey
- expect(object.errors.messages).to eql(children: ['should be an array of test objects'])
+ expect(object.errors.messages).to eq(children: ['should be an array of test objects'])
end
end
end
diff --git a/spec/validators/devise_email_validator_spec.rb b/spec/validators/devise_email_validator_spec.rb
index 29a008f858a..64d11d4d963 100644
--- a/spec/validators/devise_email_validator_spec.rb
+++ b/spec/validators/devise_email_validator_spec.rb
@@ -23,7 +23,7 @@ RSpec.describe DeviseEmailValidator do
subject
expect(user.errors).to be_present
- expect(user.errors.first[1]).to eq 'is invalid'
+ expect(user.errors.added?(:public_email)).to be true
end
it 'returns error when email is nil' do
@@ -40,7 +40,7 @@ RSpec.describe DeviseEmailValidator do
subject
expect(user.errors).to be_present
- expect(user.errors.first[1]).to eq 'is invalid'
+ expect(user.errors.added?(:public_email)).to be true
end
end
end
diff --git a/spec/validators/gitlab/utils/zoom_url_validator_spec.rb b/spec/validators/gitlab/utils/zoom_url_validator_spec.rb
index bc8236a2f5c..392d8b3a2fe 100644
--- a/spec/validators/gitlab/utils/zoom_url_validator_spec.rb
+++ b/spec/validators/gitlab/utils/zoom_url_validator_spec.rb
@@ -21,7 +21,7 @@ RSpec.describe Gitlab::Utils::ZoomUrlValidator do
expect(zoom_meeting.valid?).to eq(false)
expect(zoom_meeting.errors).to be_present
- expect(zoom_meeting.errors.first[1]).to eq 'must contain one valid Zoom URL'
+ expect(zoom_meeting.errors.added?(:url, 'must contain one valid Zoom URL')).to be true
end
end
diff --git a/spec/validators/qualified_domain_array_validator_spec.rb b/spec/validators/qualified_domain_array_validator_spec.rb
index 865ecffe05a..b2b13d358c4 100644
--- a/spec/validators/qualified_domain_array_validator_spec.rb
+++ b/spec/validators/qualified_domain_array_validator_spec.rb
@@ -52,7 +52,7 @@ RSpec.describe QualifiedDomainArrayValidator do
subject
expect(record.errors).to be_present
- expect(record.errors.first[1]).to eq('entries cannot be nil')
+ expect(record.errors.added?(:domain_array, "entries cannot be nil")).to be true
end
it 'allows when domain is valid' do
@@ -67,7 +67,7 @@ RSpec.describe QualifiedDomainArrayValidator do
subject
expect(record.errors).to be_present
- expect(record.errors.first[1]).to eq 'unicode domains should use IDNA encoding'
+ expect(record.errors.added?(:domain_array, 'unicode domains should use IDNA encoding')).to be true
end
it 'returns error when entry is larger than 255 chars' do
@@ -76,7 +76,7 @@ RSpec.describe QualifiedDomainArrayValidator do
subject
expect(record.errors).to be_present
- expect(record.errors.first[1]).to eq 'entries cannot be larger than 255 characters'
+ expect(record.errors.added?(:domain_array, 'entries cannot be larger than 255 characters')).to be true
end
it 'returns error when entry contains HTML tags' do
@@ -85,7 +85,7 @@ RSpec.describe QualifiedDomainArrayValidator do
subject
expect(record.errors).to be_present
- expect(record.errors.first[1]).to eq 'entries cannot contain HTML tags'
+ expect(record.errors.added?(:domain_array, 'entries cannot contain HTML tags')).to be true
end
end