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
bda9bfb1
Commit
bda9bfb1
authored
Aug 09, 2018
by
Chantal Rollison
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add weight to issue hook
parent
e4ce8918
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
138 additions
and
52 deletions
+138
-52
ee/changelogs/unreleased/ccr-6274-add_weight_to_payload.yml
ee/changelogs/unreleased/ccr-6274-add_weight_to_payload.yml
+5
-0
ee/lib/ee/gitlab/hook_data/issue_builder.rb
ee/lib/ee/gitlab/hook_data/issue_builder.rb
+23
-0
ee/spec/lib/ee/gitlab/hook_data/issue_builder_spec.rb
ee/spec/lib/ee/gitlab/hook_data/issue_builder_spec.rb
+52
-0
lib/gitlab/hook_data/issuable_builder.rb
lib/gitlab/hook_data/issuable_builder.rb
+1
-1
lib/gitlab/hook_data/issue_builder.rb
lib/gitlab/hook_data/issue_builder.rb
+27
-23
lib/gitlab/hook_data/merge_request_builder.rb
lib/gitlab/hook_data/merge_request_builder.rb
+30
-28
No files found.
ee/changelogs/unreleased/ccr-6274-add_weight_to_payload.yml
0 → 100644
View file @
bda9bfb1
---
title
:
Add weight to issue hook
merge_request
:
author
:
type
:
fixed
ee/lib/ee/gitlab/hook_data/issue_builder.rb
0 → 100644
View file @
bda9bfb1
# frozen_string_literal: true
module
EE
module
Gitlab
module
HookData
module
IssueBuilder
extend
ActiveSupport
::
Concern
EE_SAFE_HOOK_ATTRIBUTES
=
%i[
weight
]
.
freeze
class_methods
do
extend
::
Gitlab
::
Utils
::
Override
override
:safe_hook_attributes
def
safe_hook_attributes
super
+
EE_SAFE_HOOK_ATTRIBUTES
end
end
end
end
end
end
ee/spec/lib/ee/gitlab/hook_data/issue_builder_spec.rb
0 → 100644
View file @
bda9bfb1
# frozen_string_literal: true
require
'spec_helper'
describe
Gitlab
::
HookData
::
IssueBuilder
do
set
(
:issue
)
{
create
(
:issue
)
}
let
(
:builder
)
{
described_class
.
new
(
issue
)
}
describe
'#build'
do
let
(
:data
)
{
builder
.
build
}
it
'includes safe attribute'
do
%w[
assignee_id
author_id
closed_at
confidential
created_at
description
due_date
id
iid
last_edited_at
last_edited_by_id
milestone_id
moved_to_id
project_id
relative_position
state
time_estimate
title
updated_at
updated_by_id
weight
]
.
each
do
|
key
|
expect
(
data
).
to
include
(
key
)
end
end
it
'includes additional attr'
do
expect
(
data
).
to
include
(
:weight
)
end
context
'when the issue has an image in the description'
do
let
(
:issue_with_description
)
{
create
(
:issue
,
description:
'test![Issue_Image](/uploads/abc/Issue_Image.png)'
)
}
let
(
:builder
)
{
described_class
.
new
(
issue_with_description
)
}
it
'sets the image to use an absolute URL'
do
expect
(
data
[
:description
]).
to
eq
(
"test![Issue_Image](
#{
Settings
.
gitlab
.
url
}
/uploads/abc/Issue_Image.png)"
)
end
end
end
end
lib/gitlab/hook_data/issuable_builder.rb
View file @
bda9bfb1
...
@@ -28,7 +28,7 @@ module Gitlab
...
@@ -28,7 +28,7 @@ module Gitlab
end
end
def
safe_keys
def
safe_keys
issuable_builder
::
SAFE_HOOK_ATTRIBUTES
+
issuable_builder
::
SAFE_HOOK_RELATIONS
issuable_builder
.
safe_hook_attributes
+
issuable_builder
::
SAFE_HOOK_RELATIONS
end
end
private
private
...
...
lib/gitlab/hook_data/issue_builder.rb
View file @
bda9bfb1
module
Gitlab
module
Gitlab
module
HookData
module
HookData
class
IssueBuilder
<
BaseBuilder
class
IssueBuilder
<
BaseBuilder
SAFE_HOOK_ATTRIBUTES
=
%i[
prepend
::
EE
::
Gitlab
::
HookData
::
IssueBuilder
assignee_id
author_id
closed_at
confidential
created_at
description
due_date
id
iid
last_edited_at
last_edited_by_id
milestone_id
moved_to_id
project_id
relative_position
state
time_estimate
title
updated_at
updated_by_id
]
.
freeze
SAFE_HOOK_RELATIONS
=
%i[
SAFE_HOOK_RELATIONS
=
%i[
assignees
assignees
...
@@ -30,6 +9,31 @@ module Gitlab
...
@@ -30,6 +9,31 @@ module Gitlab
total_time_spent
total_time_spent
]
.
freeze
]
.
freeze
def
self
.
safe_hook_attributes
%i[
assignee_id
author_id
closed_at
confidential
created_at
description
due_date
id
iid
last_edited_at
last_edited_by_id
milestone_id
moved_to_id
project_id
relative_position
state
time_estimate
title
updated_at
updated_by_id
]
.
freeze
end
alias_method
:issue
,
:object
alias_method
:issue
,
:object
def
build
def
build
...
@@ -43,7 +47,7 @@ module Gitlab
...
@@ -43,7 +47,7 @@ module Gitlab
assignee_id:
issue
.
assignee_ids
.
first
# This key is deprecated
assignee_id:
issue
.
assignee_ids
.
first
# This key is deprecated
}
}
issue
.
attributes
.
with_indifferent_access
.
slice
(
*
SAFE_HOOK_ATTRIBUTES
)
issue
.
attributes
.
with_indifferent_access
.
slice
(
*
self
.
class
.
safe_hook_attributes
)
.
merge!
(
attrs
)
.
merge!
(
attrs
)
end
end
end
end
...
...
lib/gitlab/hook_data/merge_request_builder.rb
View file @
bda9bfb1
module
Gitlab
module
Gitlab
module
HookData
module
HookData
class
MergeRequestBuilder
<
BaseBuilder
class
MergeRequestBuilder
<
BaseBuilder
SAFE_HOOK_ATTRIBUTES
=
%i[
def
self
.
safe_hook_attributes
assignee_id
%i[
author_id
assignee_id
created_at
author_id
description
created_at
head_pipeline_id
description
id
head_pipeline_id
iid
id
last_edited_at
iid
last_edited_by_id
last_edited_at
merge_commit_sha
last_edited_by_id
merge_error
merge_commit_sha
merge_params
merge_error
merge_status
merge_params
merge_user_id
merge_status
merge_when_pipeline_succeeds
merge_user_id
milestone_id
merge_when_pipeline_succeeds
source_branch
milestone_id
source_project_id
source_branch
state
source_project_id
target_branch
state
target_project_id
target_branch
time_estimate
target_project_id
title
time_estimate
updated_at
title
updated_by_id
updated_at
]
.
freeze
updated_by_id
]
.
freeze
end
SAFE_HOOK_RELATIONS
=
%i[
SAFE_HOOK_RELATIONS
=
%i[
assignee
assignee
...
@@ -50,7 +52,7 @@ module Gitlab
...
@@ -50,7 +52,7 @@ module Gitlab
human_time_estimate:
merge_request
.
human_time_estimate
human_time_estimate:
merge_request
.
human_time_estimate
}
}
merge_request
.
attributes
.
with_indifferent_access
.
slice
(
*
SAFE_HOOK_ATTRIBUTES
)
merge_request
.
attributes
.
with_indifferent_access
.
slice
(
*
self
.
class
.
safe_hook_attributes
)
.
merge!
(
attrs
)
.
merge!
(
attrs
)
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