diff options
Diffstat (limited to 'spec/lib/release_highlights')
-rw-r--r-- | spec/lib/release_highlights/validator/entry_spec.rb | 19 | ||||
-rw-r--r-- | spec/lib/release_highlights/validator_spec.rb | 5 |
2 files changed, 14 insertions, 10 deletions
diff --git a/spec/lib/release_highlights/validator/entry_spec.rb b/spec/lib/release_highlights/validator/entry_spec.rb index da44938f165..5f7ccbf4310 100644 --- a/spec/lib/release_highlights/validator/entry_spec.rb +++ b/spec/lib/release_highlights/validator/entry_spec.rb @@ -40,8 +40,8 @@ RSpec.describe ReleaseHighlights::Validator::Entry do end it 'validates boolean value of "self-managed" and "gitlab-com"' do - allow(entry).to receive(:value_for).with('self-managed').and_return('nope') - allow(entry).to receive(:value_for).with('gitlab-com').and_return('yerp') + allow(entry).to receive(:value_for).with(:'self-managed').and_return('nope') + allow(entry).to receive(:value_for).with(:'gitlab-com').and_return('yerp') subject.valid? @@ -50,17 +50,18 @@ RSpec.describe ReleaseHighlights::Validator::Entry do end it 'validates URI of "url" and "image_url"' do - allow(entry).to receive(:value_for).with('image_url').and_return('imgur/gitlab_feature.gif') - allow(entry).to receive(:value_for).with('url').and_return('gitlab/newest_release.html') + stub_env('RSPEC_ALLOW_INVALID_URLS', 'false') + allow(entry).to receive(:value_for).with(:image_url).and_return('https://foobar.x/images/ci/gitlab-ci-cd-logo_2x.png') + allow(entry).to receive(:value_for).with(:url).and_return('') subject.valid? - expect(subject.errors[:url]).to include(/must be a URL/) - expect(subject.errors[:image_url]).to include(/must be a URL/) + expect(subject.errors[:url]).to include(/must be a valid URL/) + expect(subject.errors[:image_url]).to include(/is blocked: Host cannot be resolved or invalid/) end it 'validates release is numerical' do - allow(entry).to receive(:value_for).with('release').and_return('one') + allow(entry).to receive(:value_for).with(:release).and_return('one') subject.valid? @@ -68,7 +69,7 @@ RSpec.describe ReleaseHighlights::Validator::Entry do end it 'validates published_at is a date' do - allow(entry).to receive(:value_for).with('published_at').and_return('christmas day') + allow(entry).to receive(:value_for).with(:published_at).and_return('christmas day') subject.valid? @@ -76,7 +77,7 @@ RSpec.describe ReleaseHighlights::Validator::Entry do end it 'validates packages are included in list' do - allow(entry).to receive(:value_for).with('packages').and_return(['ALL']) + allow(entry).to receive(:value_for).with(:packages).and_return(['ALL']) subject.valid? diff --git a/spec/lib/release_highlights/validator_spec.rb b/spec/lib/release_highlights/validator_spec.rb index a423e8cc5f6..f30754b4167 100644 --- a/spec/lib/release_highlights/validator_spec.rb +++ b/spec/lib/release_highlights/validator_spec.rb @@ -78,7 +78,10 @@ RSpec.describe ReleaseHighlights::Validator do end describe 'when validating all files' do - it 'they should have no errors' do + # Permit DNS requests to validate all URLs in the YAML files + it 'they should have no errors', :permit_dns do + stub_env('RSPEC_ALLOW_INVALID_URLS', 'false') + expect(described_class.validate_all!).to be_truthy, described_class.error_message end end |