summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorRobert Speicher <robert@gitlab.com>2016-02-26 23:35:43 +0000
committerRobert Speicher <robert@gitlab.com>2016-02-26 23:35:43 +0000
commit20ac35e924d3cae1d3eb61385edad20c90a2322d (patch)
tree3b0e76d84d4b85bd298573452e929bc7f17dad2d /spec
parent2c6e34bc16e7d2ddea5601998a4496cc20902fe4 (diff)
parent4d0e2979b9a17160ad93ff704e7a51f78b4f3b4c (diff)
downloadgitlab-ce-20ac35e924d3cae1d3eb61385edad20c90a2322d.tar.gz
Merge branch 'evuez/gitlab-ce-webhook-url-spaces' into 'master'
Strip leading and trailing spaces in URL validator _Originally opened at !2914 by @evuez._ It makes URLs in webhooks valid even if they contain leading and/or trailing spaces. Spaces are hard to notice in input fields, this helps users by accepting leading and trailing spaces in webhooks URLs. Fixes #13652 See merge request !2939
Diffstat (limited to 'spec')
-rw-r--r--spec/models/hooks/project_hook_spec.rb4
-rw-r--r--spec/models/hooks/web_hook_spec.rb20
2 files changed, 14 insertions, 10 deletions
diff --git a/spec/models/hooks/project_hook_spec.rb b/spec/models/hooks/project_hook_spec.rb
index 645ee0b929a..983848392b7 100644
--- a/spec/models/hooks/project_hook_spec.rb
+++ b/spec/models/hooks/project_hook_spec.rb
@@ -19,6 +19,10 @@
require 'spec_helper'
describe ProjectHook, models: true do
+ describe "Associations" do
+ it { is_expected.to belong_to :project }
+ end
+
describe '.push_hooks' do
it 'should return hooks for push events only' do
hook = create(:project_hook, push_events: true)
diff --git a/spec/models/hooks/web_hook_spec.rb b/spec/models/hooks/web_hook_spec.rb
index 7070aa4ac62..6ea99952a8f 100644
--- a/spec/models/hooks/web_hook_spec.rb
+++ b/spec/models/hooks/web_hook_spec.rb
@@ -18,20 +18,14 @@
require 'spec_helper'
-describe ProjectHook, models: true do
- describe "Associations" do
- it { is_expected.to belong_to :project }
- end
-
- describe "Mass assignment" do
- end
-
+describe WebHook, models: true do
describe "Validations" do
it { is_expected.to validate_presence_of(:url) }
- context "url format" do
+ describe 'url' do
it { is_expected.to allow_value("http://example.com").for(:url) }
- it { is_expected.to allow_value("https://excample.com").for(:url) }
+ it { is_expected.to allow_value("https://example.com").for(:url) }
+ it { is_expected.to allow_value(" https://example.com ").for(:url) }
it { is_expected.to allow_value("http://test.com/api").for(:url) }
it { is_expected.to allow_value("http://test.com/api?key=abc").for(:url) }
it { is_expected.to allow_value("http://test.com/api?key=abc&type=def").for(:url) }
@@ -39,6 +33,12 @@ describe ProjectHook, models: true do
it { is_expected.not_to allow_value("example.com").for(:url) }
it { is_expected.not_to allow_value("ftp://example.com").for(:url) }
it { is_expected.not_to allow_value("herp-and-derp").for(:url) }
+
+ it 'strips :url before saving it' do
+ hook = create(:project_hook, url: ' https://example.com ')
+
+ expect(hook.url).to eq('https://example.com')
+ end
end
end