diff options
author | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2018-09-17 19:34:27 +0000 |
---|---|---|
committer | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2018-09-17 19:34:27 +0000 |
commit | 2a7b1367eb34aff8483d460cfda7b5d592585da5 (patch) | |
tree | b4e9b3849ccb8109720f935079c54e66387b27f5 /spec | |
parent | be7328dea292bb9d7b3847db990f0a62b79e3f25 (diff) | |
parent | b73f3ce58fa6bf0e75ae7f348000b7bce53da9b1 (diff) | |
download | gitlab-ce-2a7b1367eb34aff8483d460cfda7b5d592585da5.tar.gz |
Merge branch 'fix-url-validator' into 'master'
Allow UrlValidator to work with attr_encrypted
See merge request gitlab-org/gitlab-ce!21776
Diffstat (limited to 'spec')
-rw-r--r-- | spec/validators/url_validator_spec.rb | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/spec/validators/url_validator_spec.rb b/spec/validators/url_validator_spec.rb index 93fe013d11c..ab6100509a6 100644 --- a/spec/validators/url_validator_spec.rb +++ b/spec/validators/url_validator_spec.rb @@ -24,6 +24,21 @@ describe UrlValidator do expect(badge.errors.empty?).to be true end + + it 'strips urls' do + badge.link_url = "\n\r\n\nhttps://127.0.0.1\r\n\r\n\n\n\n" + + # It's unusual for a validator to modify its arguments. Some extensions, + # such as attr_encrypted, freeze the string to signal that modifications + # will not be persisted, so freeze this string to ensure the scheme is + # compatible with them. + badge.link_url.freeze + + subject + + expect(badge.errors).to be_empty + expect(badge.link_url).to eq('https://127.0.0.1') + end end context 'when allow_localhost is set to false' do |