BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
a179c5ca
Commit
a179c5ca
authored
Apr 12, 2017
by
Rémy Coutable
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'zj-api-fix-build-events' into 'master'
Api fix build events rename to Job events Closes #30412 See merge request !10586
parents
a0d734c9
e415ad39
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
24 additions
and
9 deletions
+24
-9
hooks_controller.rb
app/controllers/projects/hooks_controller.rb
+2
-2
zj-api-fix-build-events.yml
changelogs/unreleased/zj-api-fix-build-events.yml
+4
-0
project_hooks.rb
lib/api/project_hooks.rb
+9
-3
project_hooks_spec.rb
spec/requests/api/project_hooks_spec.rb
+9
-4
No files found.
app/controllers/projects/hooks_controller.rb
View file @
a179c5ca
...
...
@@ -10,7 +10,7 @@ class Projects::HooksController < Projects::ApplicationController
@hook
=
@project
.
hooks
.
new
(
hook_params
)
@hook
.
save
unless
@hook
.
valid?
unless
@hook
.
valid?
@hooks
=
@project
.
hooks
.
select
(
&
:persisted?
)
flash
[
:alert
]
=
@hook
.
errors
.
full_messages
.
join
.
html_safe
end
...
...
@@ -49,7 +49,7 @@ class Projects::HooksController < Projects::ApplicationController
def
hook_params
params
.
require
(
:hook
).
permit
(
:
build
_events
,
:
job
_events
,
:pipeline_events
,
:enable_ssl_verification
,
:issues_events
,
...
...
changelogs/unreleased/zj-api-fix-build-events.yml
0 → 100644
View file @
a179c5ca
---
title
:
"
Bugfix:
POST
/projects/:id/hooks
and
PUT
/projects/:id/hook/:hook_id
no
longer
ignore
the
the
job_events
param
in
the
V4
API"
merge_request
:
10586
author
:
lib/api/project_hooks.rb
View file @
a179c5ca
...
...
@@ -13,7 +13,7 @@ module API
optional
:merge_requests_events
,
type:
Boolean
,
desc:
"Trigger hook on merge request events"
optional
:tag_push_events
,
type:
Boolean
,
desc:
"Trigger hook on tag push events"
optional
:note_events
,
type:
Boolean
,
desc:
"Trigger hook on note(comment) events"
optional
:
build_events
,
type:
Boolean
,
desc:
"Trigger hook on build
events"
optional
:
job_events
,
type:
Boolean
,
desc:
"Trigger hook on job
events"
optional
:pipeline_events
,
type:
Boolean
,
desc:
"Trigger hook on pipeline events"
optional
:wiki_page_events
,
type:
Boolean
,
desc:
"Trigger hook on wiki events"
optional
:enable_ssl_verification
,
type:
Boolean
,
desc:
"Do SSL verification when triggering the hook"
...
...
@@ -53,7 +53,10 @@ module API
use
:project_hook_properties
end
post
":id/hooks"
do
hook
=
user_project
.
hooks
.
new
(
declared_params
(
include_missing:
false
))
hook_params
=
declared_params
(
include_missing:
false
)
hook_params
[
:build_events
]
=
hook_params
.
delete
(
:job_events
)
{
false
}
hook
=
user_project
.
hooks
.
new
(
hook_params
)
if
hook
.
save
present
hook
,
with:
Entities
::
ProjectHook
...
...
@@ -74,7 +77,10 @@ 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
))
update_params
=
declared_params
(
include_missing:
false
)
update_params
[
:build_events
]
=
update_params
.
delete
(
:job_events
)
if
update_params
[
:job_events
]
if
hook
.
update_attributes
(
update_params
)
present
hook
,
with:
Entities
::
ProjectHook
else
error!
(
"Invalid url given"
,
422
)
if
hook
.
errors
[
:url
].
present?
...
...
spec/requests/api/project_hooks_spec.rb
View file @
a179c5ca
...
...
@@ -22,8 +22,8 @@ describe API::ProjectHooks, 'ProjectHooks', api: true do
context
"authorized user"
do
it
"returns project hooks"
do
get
api
(
"/projects/
#{
project
.
id
}
/hooks"
,
user
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
json_response
).
to
be_an
Array
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
.
count
).
to
eq
(
1
)
...
...
@@ -43,6 +43,7 @@ describe API::ProjectHooks, 'ProjectHooks', api: true do
context
"unauthorized user"
do
it
"does not access project hooks"
do
get
api
(
"/projects/
#{
project
.
id
}
/hooks"
,
user3
)
expect
(
response
).
to
have_http_status
(
403
)
end
end
...
...
@@ -52,6 +53,7 @@ describe API::ProjectHooks, 'ProjectHooks', api: true do
context
"authorized user"
do
it
"returns a project hook"
do
get
api
(
"/projects/
#{
project
.
id
}
/hooks/
#{
hook
.
id
}
"
,
user
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
json_response
[
'url'
]).
to
eq
(
hook
.
url
)
expect
(
json_response
[
'issues_events'
]).
to
eq
(
hook
.
issues_events
)
...
...
@@ -67,6 +69,7 @@ describe API::ProjectHooks, 'ProjectHooks', api: true do
it
"returns a 404 error if hook id is not available"
do
get
api
(
"/projects/
#{
project
.
id
}
/hooks/1234"
,
user
)
expect
(
response
).
to
have_http_status
(
404
)
end
end
...
...
@@ -88,7 +91,8 @@ describe API::ProjectHooks, 'ProjectHooks', api: true do
it
"adds hook to project"
do
expect
do
post
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
,
job_events:
true
end
.
to
change
{
project
.
hooks
.
count
}.
by
(
1
)
expect
(
response
).
to
have_http_status
(
201
)
...
...
@@ -98,7 +102,7 @@ describe API::ProjectHooks, 'ProjectHooks', api: true 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
[
'job_events'
]).
to
eq
(
fals
e
)
expect
(
json_response
[
'job_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
)
...
...
@@ -136,7 +140,8 @@ describe API::ProjectHooks, 'ProjectHooks', api: true do
describe
"PUT /projects/:id/hooks/:hook_id"
do
it
"updates an existing project hook"
do
put
api
(
"/projects/
#{
project
.
id
}
/hooks/
#{
hook
.
id
}
"
,
user
),
url:
'http://example.org'
,
push_events:
false
url:
'http://example.org'
,
push_events:
false
,
job_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