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
Jérome Perrin
gitlab-ce
Commits
a4827ee2
Commit
a4827ee2
authored
Oct 18, 2016
by
Z.J. van de Weg
Committed by
Z.J. van de Weg
Oct 31, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Be able to POST subscriptions for system hooks
parent
76690017
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
2 deletions
+20
-2
lib/api/system_hooks.rb
lib/api/system_hooks.rb
+6
-2
spec/requests/api/system_hooks_spec.rb
spec/requests/api/system_hooks_spec.rb
+14
-0
No files found.
lib/api/system_hooks.rb
View file @
a4827ee2
...
@@ -19,10 +19,14 @@ module API
...
@@ -19,10 +19,14 @@ module API
success
Entities
::
Hook
success
Entities
::
Hook
end
end
params
do
params
do
requires
:url
,
type:
String
,
desc:
'The URL for the system hook'
requires
:url
,
type:
String
,
desc:
"The URL to send the request to"
optional
:token
,
type:
String
,
desc:
'The token used to validate payloads'
optional
:push_events
,
type:
Boolean
,
desc:
"Trigger hook on push events"
optional
:tag_push_events
,
type:
Boolean
,
desc:
"Trigger hook on tag push events"
optional
:enable_ssl_verification
,
type:
Boolean
,
desc:
"Do SSL verification when triggering the hook"
end
end
post
do
post
do
hook
=
SystemHook
.
new
declared
(
params
).
to_h
hook
=
SystemHook
.
new
declared
(
params
,
include_missing:
false
).
to_h
if
hook
.
save
if
hook
.
save
present
hook
,
with:
Entities
::
Hook
present
hook
,
with:
Entities
::
Hook
...
...
spec/requests/api/system_hooks_spec.rb
View file @
a4827ee2
...
@@ -13,6 +13,7 @@ describe API::API, api: true do
...
@@ -13,6 +13,7 @@ describe API::API, api: true do
context
"when no user"
do
context
"when no user"
do
it
"returns authentication error"
do
it
"returns authentication error"
do
get
api
(
"/hooks"
)
get
api
(
"/hooks"
)
expect
(
response
).
to
have_http_status
(
401
)
expect
(
response
).
to
have_http_status
(
401
)
end
end
end
end
...
@@ -20,6 +21,7 @@ describe API::API, api: true do
...
@@ -20,6 +21,7 @@ describe API::API, api: true do
context
"when not an admin"
do
context
"when not an admin"
do
it
"returns forbidden error"
do
it
"returns forbidden error"
do
get
api
(
"/hooks"
,
user
)
get
api
(
"/hooks"
,
user
)
expect
(
response
).
to
have_http_status
(
403
)
expect
(
response
).
to
have_http_status
(
403
)
end
end
end
end
...
@@ -27,9 +29,13 @@ describe API::API, api: true do
...
@@ -27,9 +29,13 @@ describe API::API, api: true do
context
"when authenticated as admin"
do
context
"when authenticated as admin"
do
it
"returns an array of hooks"
do
it
"returns an array of hooks"
do
get
api
(
"/hooks"
,
admin
)
get
api
(
"/hooks"
,
admin
)
byebug
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
first
[
'url'
]).
to
eq
(
hook
.
url
)
expect
(
json_response
.
first
[
'url'
]).
to
eq
(
hook
.
url
)
expect
(
json_response
.
first
[
'push_events'
]).
to
be
true
expect
(
json_response
.
first
[
'tag_push_events'
]).
to
be
false
end
end
end
end
end
end
...
@@ -51,6 +57,14 @@ describe API::API, api: true do
...
@@ -51,6 +57,14 @@ describe API::API, api: true do
post
api
(
"/hooks"
,
admin
)
post
api
(
"/hooks"
,
admin
)
end
.
not_to
change
{
SystemHook
.
count
}
end
.
not_to
change
{
SystemHook
.
count
}
end
end
it
'allows the events to be selected'
do
post
api
(
'/hooks'
,
admin
),
url:
'http://mep.mep'
,
enable_ssl_verification:
true
expect
(
response
).
to
have_http_status
(
201
)
expect
(
json_response
[
'enable_ssl_verification'
]).
to
be
true
expect
(
json_response
[
'tag_push_events'
]).
to
be
false
end
end
end
describe
"GET /hooks/:id"
do
describe
"GET /hooks/:id"
do
...
...
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