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
aeac7eb0
Commit
aeac7eb0
authored
Jun 23, 2020
by
Rémy Coutable
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Don't include changes in webhook payload when old associations are empty
Signed-off-by:
Rémy Coutable
<
remy@rymai.me
>
parent
06f1abe5
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
3 deletions
+29
-3
app/models/concerns/issuable.rb
app/models/concerns/issuable.rb
+3
-3
changelogs/unreleased/dont-include-changes-in-webhook-payload-when-old-associations-is-empty.yml
...ges-in-webhook-payload-when-old-associations-is-empty.yml
+5
-0
spec/models/concerns/issuable_spec.rb
spec/models/concerns/issuable_spec.rb
+21
-0
No files found.
app/models/concerns/issuable.rb
View file @
aeac7eb0
...
...
@@ -411,8 +411,8 @@ module Issuable
changes
=
previous_changes
if
old_associations
old_labels
=
old_associations
.
fetch
(
:labels
,
[]
)
old_assignees
=
old_associations
.
fetch
(
:assignees
,
[]
)
old_labels
=
old_associations
.
fetch
(
:labels
,
labels
)
old_assignees
=
old_associations
.
fetch
(
:assignees
,
assignees
)
if
old_labels
!=
labels
changes
[
:labels
]
=
[
old_labels
.
map
(
&
:hook_attrs
),
labels
.
map
(
&
:hook_attrs
)]
...
...
@@ -423,7 +423,7 @@ module Issuable
end
if
self
.
respond_to?
(
:total_time_spent
)
old_total_time_spent
=
old_associations
.
fetch
(
:total_time_spent
,
nil
)
old_total_time_spent
=
old_associations
.
fetch
(
:total_time_spent
,
total_time_spent
)
if
old_total_time_spent
!=
total_time_spent
changes
[
:total_time_spent
]
=
[
old_total_time_spent
,
total_time_spent
]
...
...
changelogs/unreleased/dont-include-changes-in-webhook-payload-when-old-associations-is-empty.yml
0 → 100644
View file @
aeac7eb0
---
title
:
Don't include changes in webhook payload when old associations are empty
merge_request
:
35158
author
:
type
:
fixed
spec/models/concerns/issuable_spec.rb
View file @
aeac7eb0
...
...
@@ -416,6 +416,27 @@ RSpec.describe Issuable do
describe
'#to_hook_data'
do
let
(
:builder
)
{
double
}
context
'when old_associations is empty'
do
let
(
:label
)
{
create
(
:label
)
}
before
do
issue
.
update!
(
labels:
[
label
])
issue
.
assignees
<<
user
issue
.
spend_time
(
duration:
2
,
user_id:
user
.
id
,
spent_at:
Time
.
current
)
expect
(
Gitlab
::
HookData
::
IssuableBuilder
)
.
to
receive
(
:new
).
with
(
issue
).
and_return
(
builder
)
end
it
'delegates to Gitlab::HookData::IssuableBuilder#build and does not set labels, assignees, nor total_time_spent'
do
expect
(
builder
).
to
receive
(
:build
).
with
(
user:
user
,
changes:
{})
# In some cases, old_associations is empty, e.g. on a close event
issue
.
to_hook_data
(
user
)
end
end
context
'labels are updated'
do
let
(
:labels
)
{
create_list
(
:label
,
2
)
}
...
...
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