summaryrefslogtreecommitdiff
path: root/spec/validators
diff options
context:
space:
mode:
authorNick Thomas <nick@gitlab.com>2018-09-17 16:11:12 +0100
committerNick Thomas <nick@gitlab.com>2018-09-17 19:34:40 +0100
commitb73f3ce58fa6bf0e75ae7f348000b7bce53da9b1 (patch)
treed56a14691f443096076ef0264ea0994ef67a8780 /spec/validators
parent50cb63533ff4d90ae317b20157c3fd824783fd61 (diff)
downloadgitlab-ce-b73f3ce58fa6bf0e75ae7f348000b7bce53da9b1.tar.gz
Allow UrlValidator to work with attr_encrypted
Diffstat (limited to 'spec/validators')
-rw-r--r--spec/validators/url_validator_spec.rb15
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