summaryrefslogtreecommitdiff
path: root/spec/validators/qualified_domain_array_validator_spec.rb
diff options
context:
space:
mode:
authorSimon Knox <psimyn@gmail.com>2019-08-06 15:07:18 +1000
committerSimon Knox <psimyn@gmail.com>2019-08-06 15:07:18 +1000
commitfc77b9df8b6a49c86e9c1eb949f1b1162470d2ee (patch)
tree96aad0a31543fa520626dc1c5efabff1367a0bab /spec/validators/qualified_domain_array_validator_spec.rb
parent9c71bf3e6df2dcb20ea19df21a127823bbe5e615 (diff)
parentfa216b0e86433192ba4e39a05f42217fb4685173 (diff)
downloadgitlab-ce-fc77b9df8b6a49c86e9c1eb949f1b1162470d2ee.tar.gz
Merge branch 'master' of gitlab.com:gitlab-org/gitlab-ce into alerts-dropdown-to-modal-part-2-cealerts-dropdown-to-modal-part-2-ce
Diffstat (limited to 'spec/validators/qualified_domain_array_validator_spec.rb')
-rw-r--r--spec/validators/qualified_domain_array_validator_spec.rb30
1 files changed, 11 insertions, 19 deletions
diff --git a/spec/validators/qualified_domain_array_validator_spec.rb b/spec/validators/qualified_domain_array_validator_spec.rb
index a96b00bfd1d..6beb4c67f6f 100644
--- a/spec/validators/qualified_domain_array_validator_spec.rb
+++ b/spec/validators/qualified_domain_array_validator_spec.rb
@@ -19,20 +19,19 @@ describe QualifiedDomainArrayValidator do
subject { validator.validate(record) }
- shared_examples 'cannot be blank' do
- it 'returns error when attribute is blank' do
- record.domain_array = []
+ shared_examples 'can be nil' do
+ it 'allows when attribute is nil' do
+ record.domain_array = nil
subject
- expect(record.errors).to be_present
- expect(record.errors.first[1]).to eq 'entries cannot be blank'
+ expect(record.errors).to be_empty
end
end
- shared_examples 'can be nil' do
- it 'allows when attribute is nil' do
- record.domain_array = nil
+ shared_examples 'can be blank' do
+ it 'allows when attribute is blank' do
+ record.domain_array = []
subject
@@ -43,7 +42,7 @@ describe QualifiedDomainArrayValidator do
describe 'validations' do
let(:validator) { described_class.new(attributes: [:domain_array]) }
- it_behaves_like 'cannot be blank'
+ it_behaves_like 'can be blank'
it 'returns error when attribute is nil' do
record.domain_array = nil
@@ -51,6 +50,7 @@ describe QualifiedDomainArrayValidator do
subject
expect(record.errors).to be_present
+ expect(record.errors.first[1]).to eq('entries cannot be nil')
end
it 'allows when domain is valid' do
@@ -91,21 +91,13 @@ describe QualifiedDomainArrayValidator do
let(:validator) { described_class.new(attributes: [:domain_array], allow_nil: true) }
it_behaves_like 'can be nil'
-
- it_behaves_like 'cannot be blank'
+ it_behaves_like 'can be blank'
end
context 'when allow_blank is set to true' do
let(:validator) { described_class.new(attributes: [:domain_array], allow_blank: true) }
it_behaves_like 'can be nil'
-
- it 'allows when attribute is blank' do
- record.domain_array = []
-
- subject
-
- expect(record.errors).to be_empty
- end
+ it_behaves_like 'can be blank'
end
end