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
Kazuhiko Shiozaki
gitlab-ce
Commits
21f4e5d3
Commit
21f4e5d3
authored
Dec 04, 2013
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ProjectHook API supports new event fields
Signed-off-by:
Dmitriy Zaporozhets
<
dmitriy.zaporozhets@gmail.com
>
parent
822dac87
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
4 deletions
+15
-4
doc/api/projects.md
doc/api/projects.md
+10
-0
lib/api/project_hooks.rb
lib/api/project_hooks.rb
+3
-2
spec/requests/api/project_hooks_spec.rb
spec/requests/api/project_hooks_spec.rb
+2
-2
No files found.
doc/api/projects.md
View file @
21f4e5d3
...
...
@@ -402,6 +402,10 @@ Parameters:
{
"id"
:
1
,
"url"
:
"http://example.com/hook"
,
"project_id"
:
3
,
"push_events"
:
"true"
,
"issues_events"
:
"true"
,
"merge_requests_events"
:
"true"
,
"created_at"
:
"2012-10-12T17:04:47Z"
}
```
...
...
@@ -419,6 +423,9 @@ Parameters:
+
`id`
(required) - The ID or NAME of a project
+
`url`
(required) - The hook URL
+
`push_events`
- Trigger hook on push events
+
`issues_events`
- Trigger hook on issues events
+
`merge_requests_events`
- Trigger hook on merge_requests events
### Edit project hook
...
...
@@ -434,6 +441,9 @@ Parameters:
+
`id`
(required) - The ID or NAME of a project
+
`hook_id`
(required) - The ID of a project hook
+
`url`
(required) - The hook URL
+
`push_events`
- Trigger hook on push events
+
`issues_events`
- Trigger hook on issues events
+
`merge_requests_events`
- Trigger hook on merge_requests events
### Delete project hook
...
...
lib/api/project_hooks.rb
View file @
21f4e5d3
...
...
@@ -47,8 +47,9 @@ module API
# POST /projects/:id/hooks
post
":id/hooks"
do
required_attributes!
[
:url
]
attrs
=
attributes_for_keys
[
:url
,
:push_events
,
:issues_events
,
:merge_requests_events
]
@hook
=
user_project
.
hooks
.
new
(
attrs
)
@hook
=
user_project
.
hooks
.
new
({
"url"
=>
params
[
:url
]})
if
@hook
.
save
present
@hook
,
with:
Entities
::
ProjectHook
else
...
...
@@ -70,8 +71,8 @@ module API
put
":id/hooks/:hook_id"
do
@hook
=
user_project
.
hooks
.
find
(
params
[
:hook_id
])
required_attributes!
[
:url
]
attrs
=
attributes_for_keys
[
:url
,
:push_events
,
:issues_events
,
:merge_requests_events
]
attrs
=
attributes_for_keys
[
:url
]
if
@hook
.
update_attributes
attrs
present
@hook
,
with:
Entities
::
ProjectHook
else
...
...
spec/requests/api/project_hooks_spec.rb
View file @
21f4e5d3
...
...
@@ -66,7 +66,7 @@ describe API::API, 'ProjectHooks' do
it
"should add hook to project"
do
expect
{
post
api
(
"/projects/
#{
project
.
id
}
/hooks"
,
user
),
url:
"http://example.com"
url:
"http://example.com"
,
issues_events:
true
}.
to
change
{
project
.
hooks
.
count
}.
by
(
1
)
response
.
status
.
should
==
201
end
...
...
@@ -85,7 +85,7 @@ describe API::API, 'ProjectHooks' do
describe
"PUT /projects/:id/hooks/:hook_id"
do
it
"should update an existing project hook"
do
put
api
(
"/projects/
#{
project
.
id
}
/hooks/
#{
hook
.
id
}
"
,
user
),
url:
'http://example.org'
url:
'http://example.org'
,
push_events:
false
response
.
status
.
should
==
200
json_response
[
'url'
].
should
==
'http://example.org'
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