BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
4d0e2979
Commit
4d0e2979
authored
Feb 22, 2016
by
evuez
Committed by
Robert Speicher
Feb 26, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow webhooks URL to have leading and trailing spaces
parent
01160fc0
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
18 additions
and
10 deletions
+18
-10
CHANGELOG
CHANGELOG
+1
-0
url_validator.rb
app/validators/url_validator.rb
+3
-0
project_hook_spec.rb
spec/models/hooks/project_hook_spec.rb
+4
-0
web_hook_spec.rb
spec/models/hooks/web_hook_spec.rb
+10
-10
No files found.
CHANGELOG
View file @
4d0e2979
...
...
@@ -3,6 +3,7 @@ Please view this file on the master branch, on stable branches it's out of date.
v 8.6.0 (unreleased)
- Improve the formatting for the user page bio (Connor Shea)
- Fix avatar stretching by providing a cropping feature (Johann Pardanaud)
- Strip leading and trailing spaces in URL validator (evuez)
v 8.5.1
- Fix group projects styles
...
...
app/validators/url_validator.rb
View file @
4d0e2979
...
...
@@ -29,8 +29,11 @@ class UrlValidator < ActiveModel::EachValidator
end
def
valid_url?
(
value
)
return
false
if
value
.
nil?
options
=
default_options
.
merge
(
self
.
options
)
value
.
strip!
value
=~
/\A
#{
URI
.
regexp
(
options
[
:protocols
])
}
\z/
end
end
spec/models/hooks/project_hook_spec.rb
View file @
4d0e2979
...
...
@@ -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
)
...
...
spec/models/hooks/web_hook_spec.rb
View file @
4d0e2979
...
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment