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
Boxiang Sun
gitlab-ce
Commits
e77e9b00
Commit
e77e9b00
authored
Jul 28, 2017
by
Richard Clamp
Committed by
Rémy Coutable
Jul 28, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixup POST /v3/:id/hooks and PUT /v3/:id/hooks/:hook_id
parent
699a30f0
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
5 deletions
+13
-5
changelogs/unreleased/12673-fix_v3_project_hooks_build_events
...gelogs/unreleased/12673-fix_v3_project_hooks_build_events
+4
-0
lib/api/v3/project_hooks.rb
lib/api/v3/project_hooks.rb
+6
-2
spec/requests/api/v3/project_hooks_spec.rb
spec/requests/api/v3/project_hooks_spec.rb
+3
-3
No files found.
changelogs/unreleased/12673-fix_v3_project_hooks_build_events
0 → 100644
View file @
e77e9b00
---
title: "Fix v3 api project_hooks POST and PUT operations for build_events"
merge_request: 12673
author: Richard Clamp
lib/api/v3/project_hooks.rb
View file @
e77e9b00
...
...
@@ -56,7 +56,9 @@ module API
use
:project_hook_properties
end
post
":id/hooks"
do
hook
=
user_project
.
hooks
.
new
(
declared_params
(
include_missing:
false
))
attrs
=
declared_params
(
include_missing:
false
)
attrs
[
:job_events
]
=
attrs
.
delete
(
:build_events
)
if
attrs
.
key?
(
:build_events
)
hook
=
user_project
.
hooks
.
new
(
attrs
)
if
hook
.
save
present
hook
,
with:
::
API
::
V3
::
Entities
::
ProjectHook
...
...
@@ -77,7 +79,9 @@ module API
put
":id/hooks/:hook_id"
do
hook
=
user_project
.
hooks
.
find
(
params
.
delete
(
:hook_id
))
if
hook
.
update_attributes
(
declared_params
(
include_missing:
false
))
attrs
=
declared_params
(
include_missing:
false
)
attrs
[
:job_events
]
=
attrs
.
delete
(
:build_events
)
if
attrs
.
key?
(
:build_events
)
if
hook
.
update_attributes
(
attrs
)
present
hook
,
with:
::
API
::
V3
::
Entities
::
ProjectHook
else
error!
(
"Invalid url given"
,
422
)
if
hook
.
errors
[
:url
].
present?
...
...
spec/requests/api/v3/project_hooks_spec.rb
View file @
e77e9b00
...
...
@@ -87,7 +87,7 @@ describe API::ProjectHooks, 'ProjectHooks' do
it
"adds hook to project"
do
expect
do
post
v3_api
(
"/projects/
#{
project
.
id
}
/hooks"
,
user
),
url:
"http://example.com"
,
issues_events:
true
,
wiki_page_events:
true
url:
"http://example.com"
,
issues_events:
true
,
wiki_page_events:
true
,
build_events:
true
end
.
to
change
{
project
.
hooks
.
count
}.
by
(
1
)
expect
(
response
).
to
have_http_status
(
201
)
...
...
@@ -97,7 +97,7 @@ describe API::ProjectHooks, 'ProjectHooks' do
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
[
'build_events'
]).
to
eq
(
fals
e
)
expect
(
json_response
[
'build_events'
]).
to
eq
(
tru
e
)
expect
(
json_response
[
'pipeline_events'
]).
to
eq
(
false
)
expect
(
json_response
[
'wiki_page_events'
]).
to
eq
(
true
)
expect
(
json_response
[
'enable_ssl_verification'
]).
to
eq
(
true
)
...
...
@@ -135,7 +135,7 @@ describe API::ProjectHooks, 'ProjectHooks' do
describe
"PUT /projects/:id/hooks/:hook_id"
do
it
"updates an existing project hook"
do
put
v3_api
(
"/projects/
#{
project
.
id
}
/hooks/
#{
hook
.
id
}
"
,
user
),
url:
'http://example.org'
,
push_events:
false
url:
'http://example.org'
,
push_events:
false
,
build_events:
true
expect
(
response
).
to
have_http_status
(
200
)
expect
(
json_response
[
'url'
]).
to
eq
(
'http://example.org'
)
expect
(
json_response
[
'issues_events'
]).
to
eq
(
hook
.
issues_events
)
...
...
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