From 65f7976d0cd11d91a4c0945b2c63a1aa2f888b07 Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Fri, 23 Apr 2021 09:10:03 +0000 Subject: Add latest changes from gitlab-org/gitlab@master --- spec/validators/addressable_url_validator_spec.rb | 12 +++++++----- spec/validators/array_members_validator_spec.rb | 4 ++-- spec/validators/devise_email_validator_spec.rb | 4 ++-- spec/validators/gitlab/utils/zoom_url_validator_spec.rb | 2 +- spec/validators/qualified_domain_array_validator_spec.rb | 8 ++++---- 5 files changed, 16 insertions(+), 14 deletions(-) (limited to 'spec/validators') 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 -- cgit v1.2.3