debian-mirror-gitlab/spec/validators/public_url_validator_spec.rb

29 lines
690 B
Ruby
Raw Normal View History

2018-11-08 19:23:39 +05:30
require 'spec_helper'
describe PublicUrlValidator do
2019-07-31 22:56:46 +05:30
include_examples 'url validator examples', AddressableUrlValidator::DEFAULT_OPTIONS[:schemes]
2018-11-08 19:23:39 +05:30
context 'by default' do
let(:validator) { described_class.new(attributes: [:link_url]) }
let!(:badge) { build(:badge, link_url: 'http://www.example.com') }
2019-07-31 22:56:46 +05:30
subject { validator.validate(badge) }
2018-11-08 19:23:39 +05:30
it 'blocks urls pointing to localhost' do
badge.link_url = 'https://127.0.0.1'
subject
2019-07-31 22:56:46 +05:30
expect(badge.errors).to be_present
2018-11-08 19:23:39 +05:30
end
it 'blocks urls pointing to the local network' do
badge.link_url = 'https://192.168.1.1'
subject
2019-07-31 22:56:46 +05:30
expect(badge.errors).to be_present
2018-11-08 19:23:39 +05:30
end
end
end