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
5bf2e672
Commit
5bf2e672
authored
Apr 21, 2021
by
Alex Kalderimis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add specs verifying use of build data in hooks
parent
7e275e62
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
12 deletions
+19
-12
app/models/ci/build.rb
app/models/ci/build.rb
+1
-1
spec/models/ci/build_spec.rb
spec/models/ci/build_spec.rb
+18
-11
No files found.
app/models/ci/build.rb
View file @
5bf2e672
...
...
@@ -1047,7 +1047,7 @@ module Ci
end
def
build_data
@build_data
||=
Gitlab
::
DataBuilder
::
Build
.
build
(
self
)
strong_memoize
(
:build_data
)
{
Gitlab
::
DataBuilder
::
Build
.
build
(
self
)
}
end
def
successful_deployment_status
...
...
spec/models/ci/build_spec.rb
View file @
5bf2e672
...
...
@@ -3,6 +3,8 @@
require
'spec_helper'
RSpec
.
describe
Ci
::
Build
do
include
AfterNextHelpers
let_it_be
(
:user
)
{
create
(
:user
)
}
let_it_be
(
:group
,
reload:
true
)
{
create
(
:group
)
}
let_it_be
(
:project
,
reload:
true
)
{
create
(
:project
,
:repository
,
group:
group
)
}
...
...
@@ -4679,25 +4681,30 @@ RSpec.describe Ci::Build do
end
describe
'#execute_hooks'
do
before
do
build
.
clear_memoization
(
:build_data
)
end
context
'with project hooks'
do
let
(
:build_data
)
{
double
(
:BuildData
,
dup:
double
(
:DupedData
))
}
before
do
create
(
:project_hook
,
project:
project
,
job_events:
true
)
end
it
'execute hooks'
do
expect_any_instance_of
(
ProjectHook
).
to
receive
(
:async_execute
)
it
'calls project.execute_hooks(build_data, :job_hooks)'
do
expect
(
::
Gitlab
::
DataBuilder
::
Build
)
.
to
receive
(
:build
).
with
(
build
).
and_return
(
build_data
)
expect
(
build
.
project
)
.
to
receive
(
:execute_hooks
).
with
(
build_data
.
dup
,
:job_hooks
)
build
.
execute_hooks
end
end
context
'without relevant project hooks'
do
before
do
create
(
:project_hook
,
project:
project
,
job_events:
false
)
end
it
'does not execute a hook'
do
expect_any_instance_of
(
ProjectHook
).
not_to
receive
(
:async_execute
)
context
'without project hooks'
do
it
'does not call project.execute_hooks'
do
expect
(
build
.
project
).
not_to
receive
(
:execute_hooks
)
build
.
execute_hooks
end
...
...
@@ -4708,7 +4715,7 @@ RSpec.describe Ci::Build do
create
(
:service
,
active:
true
,
job_events:
true
,
project:
project
)
end
it
'execute services'
do
it
'execute
s
services'
do
expect_any_instance_of
(
Service
).
to
receive
(
:async_execute
)
build
.
execute_hooks
...
...
@@ -4720,7 +4727,7 @@ RSpec.describe Ci::Build do
create
(
:service
,
active:
true
,
job_events:
false
,
project:
project
)
end
it
'execute services'
do
it
'
does not
execute services'
do
expect_any_instance_of
(
Service
).
not_to
receive
(
:async_execute
)
build
.
execute_hooks
...
...
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