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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
2e97db05
Commit
2e97db05
authored
May 05, 2017
by
Gabriel Mazetto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make the new repository_update_events configurable in System Hooks UI
parent
f6619809
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
54 additions
and
2 deletions
+54
-2
app/controllers/admin/hooks_controller.rb
app/controllers/admin/hooks_controller.rb
+1
-0
app/models/hooks/system_hook.rb
app/models/hooks/system_hook.rb
+3
-0
app/views/admin/hooks/_form.html.haml
app/views/admin/hooks/_form.html.haml
+8
-1
app/views/admin/hooks/index.html.haml
app/views/admin/hooks/index.html.haml
+1
-1
spec/controllers/admin/hooks_controller_spec.rb
spec/controllers/admin/hooks_controller_spec.rb
+28
-0
spec/models/hooks/system_hook_spec.rb
spec/models/hooks/system_hook_spec.rb
+13
-0
No files found.
app/controllers/admin/hooks_controller.rb
View file @
2e97db05
...
...
@@ -60,6 +60,7 @@ class Admin::HooksController < Admin::ApplicationController
:enable_ssl_verification
,
:push_events
,
:tag_push_events
,
:repository_update_events
,
:token
,
:url
)
...
...
app/models/hooks/system_hook.rb
View file @
2e97db05
class
SystemHook
<
WebHook
scope
:repository_update_hooks
,
->
{
where
(
repository_update_events:
true
)
}
default_value_for
:push_events
,
false
default_value_for
:repository_update_events
,
true
def
async_execute
(
data
,
hook_name
)
Sidekiq
::
Client
.
enqueue
(
SystemHookWorker
,
id
,
data
,
hook_name
)
end
...
...
app/views/admin/hooks/_form.html.haml
View file @
2e97db05
...
...
@@ -18,12 +18,19 @@
or adding ssh key. But you can also enable extra triggers like Push events.
.prepend-top-default
=
form
.
check_box
:repository_update_events
,
class:
'pull-left'
.prepend-left-20
=
form
.
label
:repository_update_events
,
class:
'list-label'
do
%strong
Repository update events
%p
.light
This url will be triggered when repository is updated
%div
=
form
.
check_box
:push_events
,
class:
'pull-left'
.prepend-left-20
=
form
.
label
:push_events
,
class:
'list-label'
do
%strong
Push events
%p
.light
This url will be triggered
by a push
to the repository
This url will be triggered
for each branch updated
to the repository
%div
=
form
.
check_box
:tag_push_events
,
class:
'pull-left'
.prepend-left-20
...
...
app/views/admin/hooks/index.html.haml
View file @
2e97db05
...
...
@@ -27,7 +27,7 @@
=
link_to
'Remove'
,
admin_hook_path
(
hook
),
data:
{
confirm:
'Are you sure?'
},
method: :delete
,
class:
'btn btn-remove btn-sm'
.monospace
=
hook
.
url
%div
-
%w(push_events tag_push_events issues_events note_events merge_requests_events build_events)
.
each
do
|
trigger
|
-
%w(push_events tag_push_events issues_events note_events merge_requests_events build_events
repository_update_events
)
.
each
do
|
trigger
|
-
if
hook
.
send
(
trigger
)
%span
.label.label-gray
=
trigger
.
titleize
%span
.label.label-gray
SSL Verification:
#{
hook
.
enable_ssl_verification
?
'enabled'
:
'disabled'
}
spec/controllers/admin/hooks_controller_spec.rb
0 → 100644
View file @
2e97db05
require
'spec_helper'
describe
Admin
::
HooksController
do
let
(
:admin
)
{
create
(
:admin
)
}
before
do
sign_in
(
admin
)
end
describe
'POST #create'
do
it
'sets all parameters'
do
hook_params
=
{
enable_ssl_verification:
true
,
push_events:
true
,
tag_push_events:
true
,
repository_update_events:
true
,
token:
"TEST TOKEN"
,
url:
"http://example.com"
,
}
post
:create
,
hook:
hook_params
expect
(
response
).
to
have_http_status
(
302
)
expect
(
SystemHook
.
all
.
size
).
to
eq
(
1
)
expect
(
SystemHook
.
first
).
to
have_attributes
(
hook_params
)
end
end
end
spec/models/hooks/system_hook_spec.rb
View file @
2e97db05
require
"spec_helper"
describe
SystemHook
,
models:
true
do
context
'default attributes'
do
let
(
:system_hook
)
{
build
(
:system_hook
)
}
it
'sets defined default parameters'
do
attrs
=
{
push_events:
false
,
repository_update_events:
true
,
enable_ssl_verification:
true
}
expect
(
system_hook
).
to
have_attributes
(
attrs
)
end
end
describe
"execute"
do
let
(
:system_hook
)
{
create
(
:system_hook
)
}
let
(
:user
)
{
create
(
:user
)
}
...
...
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