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
42fbe92a
Commit
42fbe92a
authored
Jun 24, 2019
by
GitLab Bot
Browse files
Options
Browse Files
Download
Plain Diff
Automatic merge of gitlab-org/gitlab-ce master
parents
ae04baf1
88c8d177
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
35 additions
and
10 deletions
+35
-10
app/models/issue.rb
app/models/issue.rb
+4
-0
changelogs/unreleased/fix-labels-in-hooks.yml
changelogs/unreleased/fix-labels-in-hooks.yml
+5
-0
lib/gitlab/data_builder/note.rb
lib/gitlab/data_builder/note.rb
+1
-1
lib/gitlab/hook_data/issue_builder.rb
lib/gitlab/hook_data/issue_builder.rb
+1
-1
spec/lib/gitlab/data_builder/note_spec.rb
spec/lib/gitlab/data_builder/note_spec.rb
+12
-7
spec/lib/gitlab/hook_data/issue_builder_spec.rb
spec/lib/gitlab/hook_data/issue_builder_spec.rb
+3
-1
spec/models/issue_spec.rb
spec/models/issue_spec.rb
+9
-0
No files found.
app/models/issue.rb
View file @
42fbe92a
...
...
@@ -254,6 +254,10 @@ class Issue < ApplicationRecord
merge_requests_closing_issues
.
count
end
def
labels_hook_attrs
labels
.
map
(
&
:hook_attrs
)
end
private
def
ensure_metrics
...
...
changelogs/unreleased/fix-labels-in-hooks.yml
0 → 100644
View file @
42fbe92a
---
title
:
Fix label serialization in issue and note hooks
merge_request
:
29850
author
:
type
:
fixed
lib/gitlab/data_builder/note.rb
View file @
42fbe92a
...
...
@@ -44,7 +44,7 @@ module Gitlab
data
[
:commit
]
=
build_data_for_commit
(
project
,
user
,
note
)
elsif
note
.
for_issue?
data
[
:issue
]
=
note
.
noteable
.
hook_attrs
data
[
:issue
][
:labels
]
=
note
.
noteable
.
labels
(
&
:hook_attrs
)
data
[
:issue
][
:labels
]
=
note
.
noteable
.
labels
_hook_attrs
elsif
note
.
for_merge_request?
data
[
:merge_request
]
=
note
.
noteable
.
hook_attrs
elsif
note
.
for_snippet?
...
...
lib/gitlab/hook_data/issue_builder.rb
View file @
42fbe92a
...
...
@@ -45,7 +45,7 @@ module Gitlab
human_time_estimate:
issue
.
human_time_estimate
,
assignee_ids:
issue
.
assignee_ids
,
assignee_id:
issue
.
assignee_ids
.
first
,
# This key is deprecated
labels:
issue
.
labels
labels:
issue
.
labels
_hook_attrs
}
issue
.
attributes
.
with_indifferent_access
.
slice
(
*
self
.
class
.
safe_hook_attributes
)
...
...
spec/lib/gitlab/data_builder/note_spec.rb
View file @
42fbe92a
...
...
@@ -38,9 +38,11 @@ describe Gitlab::DataBuilder::Note do
end
describe
'When asking for a note on issue'
do
let
(
:label
)
{
create
(
:label
,
project:
project
)
}
let
(
:issue
)
do
create
(
:issue
,
created_at:
fixed_time
,
updated_at:
fixed_time
,
project:
project
)
create
(
:
labeled_
issue
,
created_at:
fixed_time
,
updated_at:
fixed_time
,
project:
project
,
labels:
[
label
]
)
end
let
(
:note
)
do
...
...
@@ -48,13 +50,16 @@ describe Gitlab::DataBuilder::Note do
end
it
'returns the note and issue-specific data'
do
without_timestamps
=
lambda
{
|
label
|
label
.
except
(
'created_at'
,
'updated_at'
)
}
hook_attrs
=
issue
.
reload
.
hook_attrs
expect
(
data
).
to
have_key
(
:issue
)
expect
(
data
[
:issue
].
except
(
'updated_at'
))
.
to
eq
(
issue
.
reload
.
hook_attrs
.
except
(
'updated_at
'
))
expect
(
data
[
:issue
].
except
(
'updated_at'
,
'labels'
))
.
to
eq
(
hook_attrs
.
except
(
'updated_at'
,
'labels
'
))
expect
(
data
[
:issue
][
'updated_at'
])
.
to
be
>=
issue
.
hook_attrs
[
'updated_at'
]
expect
(
data
[
:issue
][
'labels'
])
.
to
eq
(
issue
.
hook_attrs
[
'labels'
]
)
.
to
be
>=
hook_attrs
[
'updated_at'
]
expect
(
data
[
:issue
][
'labels'
]
.
map
(
&
without_timestamps
)
)
.
to
eq
(
hook_attrs
[
'labels'
].
map
(
&
without_timestamps
)
)
end
context
'with confidential issue'
do
...
...
spec/lib/gitlab/hook_data/issue_builder_spec.rb
View file @
42fbe92a
require
'spec_helper'
describe
Gitlab
::
HookData
::
IssueBuilder
do
set
(
:issue
)
{
create
(
:issue
)
}
set
(
:label
)
{
create
(
:label
)
}
set
(
:issue
)
{
create
(
:labeled_issue
,
labels:
[
label
],
project:
label
.
project
)
}
let
(
:builder
)
{
described_class
.
new
(
issue
)
}
describe
'#build'
do
...
...
@@ -39,6 +40,7 @@ describe Gitlab::HookData::IssueBuilder do
expect
(
data
).
to
include
(
:human_time_estimate
)
expect
(
data
).
to
include
(
:human_total_time_spent
)
expect
(
data
).
to
include
(
:assignee_ids
)
expect
(
data
).
to
include
(
'labels'
=>
[
label
.
hook_attrs
])
end
context
'when the issue has an image in the description'
do
...
...
spec/models/issue_spec.rb
View file @
42fbe92a
...
...
@@ -862,4 +862,13 @@ describe Issue do
end
end
end
describe
"#labels_hook_attrs"
do
let
(
:label
)
{
create
(
:label
)
}
let
(
:issue
)
{
create
(
:labeled_issue
,
labels:
[
label
])
}
it
"returns a list of label hook attributes"
do
expect
(
issue
.
labels_hook_attrs
).
to
eq
([
label
.
hook_attrs
])
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