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
2cf082ec
Commit
2cf082ec
authored
Apr 10, 2017
by
Valery Sizov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Issue multiple assignee] Support multips assignee in slash commands
parent
e442812f
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
5 deletions
+31
-5
app/services/slash_commands/interpret_service.rb
app/services/slash_commands/interpret_service.rb
+8
-5
spec/services/slash_commands/interpret_service_spec.rb
spec/services/slash_commands/interpret_service_spec.rb
+23
-0
No files found.
app/services/slash_commands/interpret_service.rb
View file @
2cf082ec
...
...
@@ -86,15 +86,18 @@ module SlashCommands
current_user
.
can?
(
:"admin_
#{
issuable
.
to_ability_name
}
"
,
project
)
end
command
:assign
do
|
assignee_param
|
user
=
extract_references
(
assignee_param
,
:user
).
first
user
||=
User
.
find_by
(
username:
assignee_param
)
users
=
extract_references
(
assignee_param
,
:user
)
next
unless
user
if
users
.
empty?
users
=
User
.
find_by
(
username:
assignee_param
.
split
(
' '
).
map
(
&
:strip
))
end
next
if
users
.
empty?
if
issuable
.
is_a?
(
Issue
)
@updates
[
:assignee_ids
]
=
[
user
.
id
]
@updates
[
:assignee_ids
]
=
users
.
map
(
&
:id
)
else
@updates
[
:assignee_id
]
=
user
.
id
@updates
[
:assignee_id
]
=
user
s
.
last
.
id
end
end
...
...
spec/services/slash_commands/interpret_service_spec.rb
View file @
2cf082ec
...
...
@@ -3,6 +3,7 @@ require 'spec_helper'
describe
SlashCommands
::
InterpretService
,
services:
true
do
let
(
:project
)
{
create
(
:project
,
:public
)
}
let
(
:developer
)
{
create
(
:user
)
}
let
(
:developer2
)
{
create
(
:user
)
}
let
(
:issue
)
{
create
(
:issue
,
project:
project
)
}
let
(
:milestone
)
{
create
(
:milestone
,
project:
project
,
title:
'9.10'
)
}
let
(
:inprogress
)
{
create
(
:label
,
project:
project
,
title:
'In Progress'
)
}
...
...
@@ -388,6 +389,28 @@ describe SlashCommands::InterpretService, services: true do
end
end
context
'assign command with multiple assignees'
do
let
(
:content
)
{
"/assign @
#{
developer
.
username
}
@
#{
developer2
.
username
}
"
}
before
{
project
.
team
<<
[
developer2
,
:developer
]
}
context
'Issue'
do
it
'fetches assignee and populates assignee_id if content contains /assign'
do
_
,
updates
=
service
.
execute
(
content
,
issue
)
expect
(
updates
[
:assignee_ids
]).
to
match_array
([
developer
.
id
,
developer2
.
id
])
end
end
context
'Merge Request'
do
it
'fetches assignee and populates assignee_id if content contains /assign'
do
_
,
updates
=
service
.
execute
(
content
,
merge_request
)
expect
(
updates
).
to
eq
(
assignee_id:
developer
.
id
)
end
end
end
it_behaves_like
'empty command'
do
let
(
:content
)
{
'/assign @abcd1234'
}
let
(
:issuable
)
{
issue
}
...
...
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