Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Léo-Paul Géneau
gitlab-ce
Commits
53f4f849
Commit
53f4f849
authored
Jan 18, 2017
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add URL validations for generic commit statuses
parent
2e088c06
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
3 deletions
+17
-3
app/models/generic_commit_status.rb
app/models/generic_commit_status.rb
+4
-0
spec/models/generic_commit_status_spec.rb
spec/models/generic_commit_status_spec.rb
+7
-0
spec/requests/api/commit_statuses_spec.rb
spec/requests/api/commit_statuses_spec.rb
+6
-3
No files found.
app/models/generic_commit_status.rb
View file @
53f4f849
class
GenericCommitStatus
<
CommitStatus
before_validation
:set_default_values
validates
:target_url
,
addressable_url:
true
,
length:
{
maximum:
255
},
allow_nil:
true
# GitHub compatible API
alias_attribute
:context
,
:name
...
...
spec/models/generic_commit_status_spec.rb
View file @
53f4f849
...
...
@@ -10,6 +10,13 @@ describe GenericCommitStatus, models: true do
target_url:
external_url
)
end
describe
'validations'
do
it
{
is_expected
.
to
validate_length_of
(
:target_url
).
is_at_most
(
255
)
}
it
{
is_expected
.
to
allow_value
(
nil
).
for
(
:target_url
)
}
it
{
is_expected
.
to
allow_value
(
'http://gitlab.com/s'
).
for
(
:target_url
)
}
it
{
is_expected
.
not_to
allow_value
(
'javascript:alert(1)'
).
for
(
:target_url
)
}
end
describe
'#context'
do
subject
{
generic_commit_status
.
context
}
before
{
generic_commit_status
.
context
=
'my_context'
}
...
...
spec/requests/api/commit_statuses_spec.rb
View file @
53f4f849
...
...
@@ -152,8 +152,11 @@ describe API::CommitStatuses, api: true do
context
'with all optional parameters'
do
before
do
optional_params
=
{
state:
'success'
,
context:
'coverage'
,
ref:
'develop'
,
target_url:
'url'
,
description:
'test'
}
optional_params
=
{
state:
'success'
,
context:
'coverage'
,
ref:
'develop'
,
description:
'test'
,
target_url:
'http://gitlab.com/status'
}
post
api
(
post_url
,
developer
),
optional_params
end
...
...
@@ -164,8 +167,8 @@ describe API::CommitStatuses, api: true do
expect
(
json_response
[
'status'
]).
to
eq
(
'success'
)
expect
(
json_response
[
'name'
]).
to
eq
(
'coverage'
)
expect
(
json_response
[
'ref'
]).
to
eq
(
'develop'
)
expect
(
json_response
[
'target_url'
]).
to
eq
(
'url'
)
expect
(
json_response
[
'description'
]).
to
eq
(
'test'
)
expect
(
json_response
[
'target_url'
]).
to
eq
(
'http://gitlab.com/status'
)
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