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
d5e73ae6
Commit
d5e73ae6
authored
Sep 24, 2015
by
Stan Hu
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'hook-api-updates' into 'master'
Hook api updates See merge request !1429
parents
817a6089
869bab9d
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
38 additions
and
4 deletions
+38
-4
CHANGELOG
CHANGELOG
+1
-0
doc/api/projects.md
doc/api/projects.md
+6
-0
lib/api/entities.rb
lib/api/entities.rb
+1
-1
lib/api/project_hooks.rb
lib/api/project_hooks.rb
+4
-2
spec/requests/api/project_hooks_spec.rb
spec/requests/api/project_hooks_spec.rb
+26
-1
No files found.
CHANGELOG
View file @
d5e73ae6
...
@@ -9,6 +9,7 @@ v 8.1.0 (unreleased)
...
@@ -9,6 +9,7 @@ v 8.1.0 (unreleased)
- Show CI status on commit page
- Show CI status on commit page
- Show CI status on Your projects page and Starred projects page
- Show CI status on Your projects page and Starred projects page
- Remove "Continuous Integration" page from dashboard
- Remove "Continuous Integration" page from dashboard
- Add notes and SSL verification entries to hook APIs (Ben Boeckel)
v 8.0.2 (unreleased)
v 8.0.2 (unreleased)
- Fix default avatar not rendering in network graph (Stan Hu)
- Fix default avatar not rendering in network graph (Stan Hu)
...
...
doc/api/projects.md
View file @
d5e73ae6
...
@@ -515,6 +515,8 @@ Parameters:
...
@@ -515,6 +515,8 @@ Parameters:
"push_events"
:
"true"
,
"push_events"
:
"true"
,
"issues_events"
:
"true"
,
"issues_events"
:
"true"
,
"merge_requests_events"
:
"true"
,
"merge_requests_events"
:
"true"
,
"note_events"
:
"true"
,
"enable_ssl_verification"
:
"true"
,
"created_at"
:
"2012-10-12T17:04:47Z"
"created_at"
:
"2012-10-12T17:04:47Z"
}
}
```
```
...
@@ -535,6 +537,8 @@ Parameters:
...
@@ -535,6 +537,8 @@ Parameters:
-
`issues_events`
- Trigger hook on issues events
-
`issues_events`
- Trigger hook on issues events
-
`merge_requests_events`
- Trigger hook on merge_requests events
-
`merge_requests_events`
- Trigger hook on merge_requests events
-
`tag_push_events`
- Trigger hook on push_tag events
-
`tag_push_events`
- Trigger hook on push_tag events
-
`note_events`
- Trigger hook on note events
-
`enable_ssl_verification`
- Do SSL verification when triggering the hook
### Edit project hook
### Edit project hook
...
@@ -553,6 +557,8 @@ Parameters:
...
@@ -553,6 +557,8 @@ Parameters:
-
`issues_events`
- Trigger hook on issues events
-
`issues_events`
- Trigger hook on issues events
-
`merge_requests_events`
- Trigger hook on merge_requests events
-
`merge_requests_events`
- Trigger hook on merge_requests events
-
`tag_push_events`
- Trigger hook on push_tag events
-
`tag_push_events`
- Trigger hook on push_tag events
-
`note_events`
- Trigger hook on note events
-
`enable_ssl_verification`
- Do SSL verification when triggering the hook
### Delete project hook
### Delete project hook
...
...
lib/api/entities.rb
View file @
d5e73ae6
...
@@ -45,7 +45,7 @@ module API
...
@@ -45,7 +45,7 @@ module API
class
ProjectHook
<
Hook
class
ProjectHook
<
Hook
expose
:project_id
,
:push_events
expose
:project_id
,
:push_events
expose
:issues_events
,
:merge_requests_events
,
:tag_push_events
expose
:issues_events
,
:merge_requests_events
,
:tag_push_events
,
:note_events
,
:enable_ssl_verification
end
end
class
ForkedFromProject
<
Grape
::
Entity
class
ForkedFromProject
<
Grape
::
Entity
...
...
lib/api/project_hooks.rb
View file @
d5e73ae6
...
@@ -44,7 +44,8 @@ module API
...
@@ -44,7 +44,8 @@ module API
:issues_events
,
:issues_events
,
:merge_requests_events
,
:merge_requests_events
,
:tag_push_events
,
:tag_push_events
,
:note_events
:note_events
,
:enable_ssl_verification
]
]
@hook
=
user_project
.
hooks
.
new
(
attrs
)
@hook
=
user_project
.
hooks
.
new
(
attrs
)
...
@@ -75,7 +76,8 @@ module API
...
@@ -75,7 +76,8 @@ module API
:issues_events
,
:issues_events
,
:merge_requests_events
,
:merge_requests_events
,
:tag_push_events
,
:tag_push_events
,
:note_events
:note_events
,
:enable_ssl_verification
]
]
if
@hook
.
update_attributes
attrs
if
@hook
.
update_attributes
attrs
...
...
spec/requests/api/project_hooks_spec.rb
View file @
d5e73ae6
...
@@ -5,7 +5,7 @@ describe API::API, 'ProjectHooks', api: true do
...
@@ -5,7 +5,7 @@ describe API::API, 'ProjectHooks', api: true do
let
(
:user
)
{
create
(
:user
)
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:user3
)
{
create
(
:user
)
}
let
(
:user3
)
{
create
(
:user
)
}
let!
(
:project
)
{
create
(
:project
,
creator_id:
user
.
id
,
namespace:
user
.
namespace
)
}
let!
(
:project
)
{
create
(
:project
,
creator_id:
user
.
id
,
namespace:
user
.
namespace
)
}
let!
(
:hook
)
{
create
(
:project_hook
,
project:
project
,
url:
"http://example.com"
)
}
let!
(
:hook
)
{
create
(
:project_hook
,
project:
project
,
url:
"http://example.com"
,
push_events:
true
,
merge_requests_events:
true
,
tag_push_events:
true
,
issues_events:
true
,
note_events:
true
,
enable_ssl_verification:
true
)
}
before
do
before
do
project
.
team
<<
[
user
,
:master
]
project
.
team
<<
[
user
,
:master
]
...
@@ -21,6 +21,12 @@ describe API::API, 'ProjectHooks', api: true do
...
@@ -21,6 +21,12 @@ describe API::API, 'ProjectHooks', api: true do
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
count
).
to
eq
(
1
)
expect
(
json_response
.
count
).
to
eq
(
1
)
expect
(
json_response
.
first
[
'url'
]).
to
eq
(
"http://example.com"
)
expect
(
json_response
.
first
[
'url'
]).
to
eq
(
"http://example.com"
)
expect
(
json_response
.
first
[
'issues_events'
]).
to
eq
(
true
)
expect
(
json_response
.
first
[
'push_events'
]).
to
eq
(
true
)
expect
(
json_response
.
first
[
'merge_requests_events'
]).
to
eq
(
true
)
expect
(
json_response
.
first
[
'tag_push_events'
]).
to
eq
(
true
)
expect
(
json_response
.
first
[
'note_events'
]).
to
eq
(
true
)
expect
(
json_response
.
first
[
'enable_ssl_verification'
]).
to
eq
(
true
)
end
end
end
end
...
@@ -38,6 +44,12 @@ describe API::API, 'ProjectHooks', api: true do
...
@@ -38,6 +44,12 @@ describe API::API, 'ProjectHooks', api: true do
get
api
(
"/projects/
#{
project
.
id
}
/hooks/
#{
hook
.
id
}
"
,
user
)
get
api
(
"/projects/
#{
project
.
id
}
/hooks/
#{
hook
.
id
}
"
,
user
)
expect
(
response
.
status
).
to
eq
(
200
)
expect
(
response
.
status
).
to
eq
(
200
)
expect
(
json_response
[
'url'
]).
to
eq
(
hook
.
url
)
expect
(
json_response
[
'url'
]).
to
eq
(
hook
.
url
)
expect
(
json_response
[
'issues_events'
]).
to
eq
(
hook
.
issues_events
)
expect
(
json_response
[
'push_events'
]).
to
eq
(
hook
.
push_events
)
expect
(
json_response
[
'merge_requests_events'
]).
to
eq
(
hook
.
merge_requests_events
)
expect
(
json_response
[
'tag_push_events'
]).
to
eq
(
hook
.
tag_push_events
)
expect
(
json_response
[
'note_events'
]).
to
eq
(
hook
.
note_events
)
expect
(
json_response
[
'enable_ssl_verification'
]).
to
eq
(
hook
.
enable_ssl_verification
)
end
end
it
"should return a 404 error if hook id is not available"
do
it
"should return a 404 error if hook id is not available"
do
...
@@ -65,6 +77,13 @@ describe API::API, 'ProjectHooks', api: true do
...
@@ -65,6 +77,13 @@ describe API::API, 'ProjectHooks', api: true do
post
api
(
"/projects/
#{
project
.
id
}
/hooks"
,
user
),
url:
"http://example.com"
,
issues_events:
true
post
api
(
"/projects/
#{
project
.
id
}
/hooks"
,
user
),
url:
"http://example.com"
,
issues_events:
true
end
.
to
change
{
project
.
hooks
.
count
}.
by
(
1
)
end
.
to
change
{
project
.
hooks
.
count
}.
by
(
1
)
expect
(
response
.
status
).
to
eq
(
201
)
expect
(
response
.
status
).
to
eq
(
201
)
expect
(
json_response
[
'url'
]).
to
eq
(
'http://example.com'
)
expect
(
json_response
[
'issues_events'
]).
to
eq
(
true
)
expect
(
json_response
[
'push_events'
]).
to
eq
(
true
)
expect
(
json_response
[
'merge_requests_events'
]).
to
eq
(
false
)
expect
(
json_response
[
'tag_push_events'
]).
to
eq
(
false
)
expect
(
json_response
[
'note_events'
]).
to
eq
(
false
)
expect
(
json_response
[
'enable_ssl_verification'
]).
to
eq
(
true
)
end
end
it
"should return a 400 error if url not given"
do
it
"should return a 400 error if url not given"
do
...
@@ -84,6 +103,12 @@ describe API::API, 'ProjectHooks', api: true do
...
@@ -84,6 +103,12 @@ describe API::API, 'ProjectHooks', api: true do
url:
'http://example.org'
,
push_events:
false
url:
'http://example.org'
,
push_events:
false
expect
(
response
.
status
).
to
eq
(
200
)
expect
(
response
.
status
).
to
eq
(
200
)
expect
(
json_response
[
'url'
]).
to
eq
(
'http://example.org'
)
expect
(
json_response
[
'url'
]).
to
eq
(
'http://example.org'
)
expect
(
json_response
[
'issues_events'
]).
to
eq
(
hook
.
issues_events
)
expect
(
json_response
[
'push_events'
]).
to
eq
(
false
)
expect
(
json_response
[
'merge_requests_events'
]).
to
eq
(
hook
.
merge_requests_events
)
expect
(
json_response
[
'tag_push_events'
]).
to
eq
(
hook
.
tag_push_events
)
expect
(
json_response
[
'note_events'
]).
to
eq
(
hook
.
note_events
)
expect
(
json_response
[
'enable_ssl_verification'
]).
to
eq
(
hook
.
enable_ssl_verification
)
end
end
it
"should return 404 error if hook id not found"
do
it
"should return 404 error if hook id not found"
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