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
45647951
Commit
45647951
authored
Jan 24, 2018
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Execute system hooks after-commit when executing project hooks
parent
09da89e6
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
27 additions
and
3 deletions
+27
-3
app/models/project.rb
app/models/project.rb
+2
-2
changelogs/unreleased/dm-project-system-hooks-in-transaction.yml
...ogs/unreleased/dm-project-system-hooks-in-transaction.yml
+5
-0
spec/models/project_spec.rb
spec/models/project_spec.rb
+17
-0
spec/services/issues/move_service_spec.rb
spec/services/issues/move_service_spec.rb
+3
-1
No files found.
app/models/project.rb
View file @
45647951
...
@@ -971,10 +971,10 @@ class Project < ActiveRecord::Base
...
@@ -971,10 +971,10 @@ class Project < ActiveRecord::Base
hooks
.
hooks_for
(
hooks_scope
).
each
do
|
hook
|
hooks
.
hooks_for
(
hooks_scope
).
each
do
|
hook
|
hook
.
async_execute
(
data
,
hooks_scope
.
to_s
)
hook
.
async_execute
(
data
,
hooks_scope
.
to_s
)
end
end
end
SystemHooksService
.
new
.
execute_hooks
(
data
,
hooks_scope
)
SystemHooksService
.
new
.
execute_hooks
(
data
,
hooks_scope
)
end
end
end
def
execute_services
(
data
,
hooks_scope
=
:push_hooks
)
def
execute_services
(
data
,
hooks_scope
=
:push_hooks
)
# Call only service hooks that are active for this scope
# Call only service hooks that are active for this scope
...
...
changelogs/unreleased/dm-project-system-hooks-in-transaction.yml
0 → 100644
View file @
45647951
---
title
:
Execute system hooks after-commit when executing project hooks
merge_request
:
author
:
type
:
fixed
spec/models/project_spec.rb
View file @
45647951
...
@@ -3228,5 +3228,22 @@ describe Project do
...
@@ -3228,5 +3228,22 @@ describe Project do
project
=
build
(
:project
)
project
=
build
(
:project
)
project
.
execute_hooks
({
data:
'data'
},
:merge_request_hooks
)
project
.
execute_hooks
({
data:
'data'
},
:merge_request_hooks
)
end
end
it
'executes the system hooks when inside a transaction'
do
allow_any_instance_of
(
WebHookService
).
to
receive
(
:execute
)
create
(
:system_hook
,
merge_requests_events:
true
)
project
=
build
(
:project
)
# Ideally, we'd test that `WebHookWorker.jobs.size` increased by 1,
# but since the entire spec run takes place in a transaction, we never
# actually get to the `after_commit` hook that queues these jobs.
expect
do
project
.
transaction
do
project
.
execute_hooks
({
data:
'data'
},
:merge_request_hooks
)
end
end
.
not_to
raise_error
# Sidekiq::Worker::EnqueueFromTransactionError
end
end
end
end
end
spec/services/issues/move_service_spec.rb
View file @
45647951
...
@@ -297,9 +297,11 @@ describe Issues::MoveService do
...
@@ -297,9 +297,11 @@ describe Issues::MoveService do
end
end
context
'project issue hooks'
do
context
'project issue hooks'
do
let
(
:hook
)
{
create
(
:project_hook
,
project:
old_project
,
issues_events:
true
)
}
let
!
(
:hook
)
{
create
(
:project_hook
,
project:
old_project
,
issues_events:
true
)
}
it
'executes project issue hooks'
do
it
'executes project issue hooks'
do
allow_any_instance_of
(
WebHookService
).
to
receive
(
:execute
)
# Ideally, we'd test that `WebHookWorker.jobs.size` increased by 1,
# Ideally, we'd test that `WebHookWorker.jobs.size` increased by 1,
# but since the entire spec run takes place in a transaction, we never
# but since the entire spec run takes place in a transaction, we never
# actually get to the `after_commit` hook that queues these jobs.
# actually get to the `after_commit` hook that queues these jobs.
...
...
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