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
9f7811e4
Commit
9f7811e4
authored
Sep 13, 2017
by
Alexis Reigel
Committed by
Alexis Reigel
Jan 04, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
execute system hooks from project
parent
fb583c4b
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
32 additions
and
2 deletions
+32
-2
app/models/hooks/system_hook.rb
app/models/hooks/system_hook.rb
+3
-1
app/models/project.rb
app/models/project.rb
+4
-0
spec/models/hooks/system_hook_spec.rb
spec/models/hooks/system_hook_spec.rb
+2
-1
spec/models/project_spec.rb
spec/models/project_spec.rb
+23
-0
No files found.
app/models/hooks/system_hook.rb
View file @
9f7811e4
...
...
@@ -2,7 +2,8 @@ class SystemHook < WebHook
TRIGGERS
=
{
repository_update_hooks: :repository_update_events
,
push_hooks: :push_events
,
tag_push_hooks: :tag_push_events
tag_push_hooks: :tag_push_events
,
merge_request_hooks: :merge_requests_events
}.
freeze
TRIGGERS
.
each
do
|
trigger
,
event
|
...
...
@@ -11,4 +12,5 @@ class SystemHook < WebHook
default_value_for
:push_events
,
false
default_value_for
:repository_update_events
,
true
default_value_for
:merge_requests_events
,
false
end
app/models/project.rb
View file @
9f7811e4
...
...
@@ -974,6 +974,10 @@ class Project < ActiveRecord::Base
hook
.
async_execute
(
data
,
hooks_scope
.
to_s
)
end
end
SystemHook
.
public_send
(
hooks_scope
).
each
do
|
hook
|
# rubocop:disable GitlabSecurity/PublicSend
hook
.
async_execute
(
data
,
hooks_scope
.
to_s
)
end
end
def
execute_services
(
data
,
hooks_scope
=
:push_hooks
)
...
...
spec/models/hooks/system_hook_spec.rb
View file @
9f7811e4
...
...
@@ -7,7 +7,8 @@ describe SystemHook do
it
'sets defined default parameters'
do
attrs
=
{
push_events:
false
,
repository_update_events:
true
repository_update_events:
true
,
merge_requests_events:
false
}
expect
(
system_hook
).
to
have_attributes
(
attrs
)
end
...
...
spec/models/project_spec.rb
View file @
9f7811e4
...
...
@@ -3177,4 +3177,27 @@ describe Project do
expect
{
project
.
write_repository_config
}.
not_to
raise_error
end
end
describe
'#execute_hooks'
do
it
'executes the projects hooks with the specified scope'
do
hook1
=
create
(
:project_hook
,
merge_requests_events:
true
,
tag_push_events:
false
)
hook2
=
create
(
:project_hook
,
merge_requests_events:
false
,
tag_push_events:
true
)
project
=
create
(
:project
,
hooks:
[
hook1
,
hook2
])
expect_any_instance_of
(
ProjectHook
).
to
receive
(
:async_execute
).
once
project
.
execute_hooks
({},
:tag_push_hooks
)
end
it
'executes the system hooks with the specified scope'
do
create
:system_hook
,
merge_requests_events:
true
,
tag_push_events:
false
create
:system_hook
,
merge_requests_events:
false
,
tag_push_events:
true
allow_any_instance_of
(
SystemHook
).
to
receive
(
:async_execute
).
once
project
=
create
:project
expect_any_instance_of
(
SystemHook
).
to
receive
(
:async_execute
).
once
project
.
execute_hooks
({},
:tag_push_hooks
)
end
end
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