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
49c776f8
Commit
49c776f8
authored
Apr 12, 2022
by
Alishan Ladhani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Guard against Deployment#deployed_by being nil
Changelog: fixed
parent
e4580caf
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
4 deletions
+27
-4
lib/gitlab/data_builder/deployment.rb
lib/gitlab/data_builder/deployment.rb
+7
-2
spec/lib/gitlab/data_builder/deployment_spec.rb
spec/lib/gitlab/data_builder/deployment_spec.rb
+20
-2
No files found.
lib/gitlab/data_builder/deployment.rb
View file @
49c776f8
...
...
@@ -17,6 +17,11 @@ module Gitlab
Gitlab
::
UrlBuilder
.
build
(
commit
)
end
user_url
=
if
deployment
.
deployed_by
Gitlab
::
UrlBuilder
.
build
(
deployment
.
deployed_by
)
end
{
object_kind:
'deployment'
,
status:
deployment
.
status
,
...
...
@@ -27,8 +32,8 @@ module Gitlab
environment:
deployment
.
environment
.
name
,
project:
deployment
.
project
.
hook_attrs
,
short_sha:
deployment
.
short_sha
,
user:
deployment
.
deployed_by
.
hook_attrs
,
user_url:
Gitlab
::
UrlBuilder
.
build
(
deployment
.
deployed_by
)
,
user:
deployment
.
deployed_by
&
.
hook_attrs
,
user_url:
user_url
,
commit_url:
commit_url
,
commit_title:
deployment
.
commit_title
,
ref:
deployment
.
ref
...
...
spec/lib/gitlab/data_builder/deployment_spec.rb
View file @
49c776f8
...
...
@@ -57,13 +57,31 @@ RSpec.describe Gitlab::DataBuilder::Deployment do
project
.
repository
.
remove
end
it
'
does not include
commit_url'
do
it
'
returns nil for
commit_url'
do
expect
(
data
[
:commit_url
]).
to
be_nil
end
it
'
does not include
commit_title'
do
it
'
returns nil for
commit_title'
do
expect
(
data
[
:commit_title
]).
to
be_nil
end
end
context
'when deployed_by is nil'
do
let_it_be
(
:deployment
)
{
create
(
:deployment
,
user:
nil
,
deployable:
nil
)
}
subject
(
:data
)
{
described_class
.
build
(
deployment
,
Time
.
current
)
}
before
(
:all
)
do
deployment
.
user
=
nil
end
it
'returns nil for user'
do
expect
(
data
[
:user
]).
to
be_nil
end
it
'returns nil for user_url'
do
expect
(
data
[
:user_url
]).
to
be_nil
end
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