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
a9dc6d28
Commit
a9dc6d28
authored
May 31, 2017
by
Valery Sizov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix: /assignee should add assignees to MR and replace in an issue
parent
18444153
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
5 deletions
+22
-5
app/services/slash_commands/interpret_service.rb
app/services/slash_commands/interpret_service.rb
+14
-3
spec/services/slash_commands/interpret_service_spec.rb
spec/services/slash_commands/interpret_service_spec.rb
+8
-2
No files found.
app/services/slash_commands/interpret_service.rb
View file @
a9dc6d28
...
...
@@ -92,9 +92,19 @@ module SlashCommands
desc
'Assign'
explanation
do
|
users
|
"Assigns
#{
users
.
map
(
&
:to_reference
).
to_sentence
}
."
if
users
.
any?
if
issuable
.
is_a?
(
Issue
)
"Assigns
#{
users
.
map
(
&
:to_reference
).
to_sentence
}
."
if
users
.
any?
else
"Assigns
#{
users
.
last
.
to_reference
}
."
if
users
.
any?
end
end
params
do
if
issuable
.
is_a?
(
Issue
)
[
'@user1 @user2'
]
else
[
'@user'
]
end
end
params
'@user'
condition
do
current_user
.
can?
(
:"admin_
#{
issuable
.
to_ability_name
}
"
,
project
)
end
...
...
@@ -105,7 +115,8 @@ module SlashCommands
next
if
users
.
empty?
if
issuable
.
is_a?
(
Issue
)
@updates
[
:assignee_ids
]
=
users
.
map
(
&
:id
)
# EE specific. In CE we should replace one assignee with another
@updates
[
:assignee_ids
]
=
issuable
.
assignees
.
pluck
(
:id
)
+
users
.
map
(
&
:id
)
else
@updates
[
:assignee_id
]
=
users
.
last
.
id
end
...
...
spec/services/slash_commands/interpret_service_spec.rb
View file @
a9dc6d28
...
...
@@ -376,15 +376,21 @@ describe SlashCommands::InterpretService, services: true do
let
(
:content
)
{
"/assign @
#{
developer
.
username
}
"
}
context
'Issue'
do
it
'fetches assignee and populates assignee_id if content contains /assign'
do
it
'fetches assignees and populates them if content contains /assign'
do
user
=
create
(
:user
)
issue
.
assignees
<<
user
_
,
updates
=
service
.
execute
(
content
,
issue
)
expect
(
updates
).
to
eq
(
assignee_ids:
[
develop
er
.
id
])
expect
(
updates
[
:assignee_ids
]).
to
match_array
([
developer
.
id
,
us
er
.
id
])
end
end
context
'Merge Request'
do
it
'fetches assignee and populates assignee_id if content contains /assign'
do
user
=
create
(
:user
)
merge_request
.
update
(
assignee:
user
)
_
,
updates
=
service
.
execute
(
content
,
merge_request
)
expect
(
updates
).
to
eq
(
assignee_id:
developer
.
id
)
...
...
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