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
bd65eabe
Commit
bd65eabe
authored
Apr 05, 2017
by
Valery Sizov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Multiple issue assignees] Fix slash commands[ci skip]
parent
7934e400
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
50 additions
and
35 deletions
+50
-35
app/services/issues/base_service.rb
app/services/issues/base_service.rb
+1
-1
app/services/slash_commands/interpret_service.rb
app/services/slash_commands/interpret_service.rb
+13
-3
spec/services/notes/slash_commands_service_spec.rb
spec/services/notes/slash_commands_service_spec.rb
+2
-2
spec/services/slash_commands/interpret_service_spec.rb
spec/services/slash_commands/interpret_service_spec.rb
+34
-29
No files found.
app/services/issues/base_service.rb
View file @
bd65eabe
...
...
@@ -22,7 +22,7 @@ module Issues
end
def
filter_assignee
(
issuable
)
return
if
params
[
:assignee_ids
].
to_a
.
empty?
return
if
params
[
:assignee_ids
].
empty?
assignee_ids
=
params
[
:assignee_ids
].
select
{
|
assignee_id
|
assignee_can_read?
(
issuable
,
assignee_id
)}
...
...
app/services/slash_commands/interpret_service.rb
View file @
bd65eabe
...
...
@@ -89,17 +89,27 @@ module SlashCommands
user
=
extract_references
(
assignee_param
,
:user
).
first
user
||=
User
.
find_by
(
username:
assignee_param
)
@updates
[
:assignee_id
]
=
user
.
id
if
user
next
unless
user
if
issuable
.
is_a?
(
Issue
)
@updates
[
:assignee_ids
]
=
[
user
.
id
]
else
@updates
[
:assignee_id
]
=
user
.
id
end
end
desc
'Remove assignee'
condition
do
issuable
.
persisted?
&&
issuable
.
assignee
_id
?
&&
issuable
.
assignee
s
.
any
?
&&
current_user
.
can?
(
:"admin_
#{
issuable
.
to_ability_name
}
"
,
project
)
end
command
:unassign
do
@updates
[
:assignee_id
]
=
nil
if
issuable
.
is_a?
(
Issue
)
@updates
[
:assignee_ids
]
=
[]
else
@updates
[
:assignee_id
]
=
nil
end
end
desc
'Set milestone'
...
...
spec/services/notes/slash_commands_service_spec.rb
View file @
bd65eabe
...
...
@@ -66,7 +66,7 @@ describe Notes::SlashCommandsService, services: true do
expect
(
content
).
to
eq
''
expect
(
note
.
noteable
).
to
be_closed
expect
(
note
.
noteable
.
labels
).
to
match_array
(
labels
)
expect
(
note
.
noteable
.
assignee
).
to
eq
(
assignee
)
expect
(
note
.
noteable
.
assignee
s
).
to
eq
([
assignee
]
)
expect
(
note
.
noteable
.
milestone
).
to
eq
(
milestone
)
end
end
...
...
@@ -113,7 +113,7 @@ describe Notes::SlashCommandsService, services: true do
expect
(
content
).
to
eq
"HELLO
\n
WORLD"
expect
(
note
.
noteable
).
to
be_closed
expect
(
note
.
noteable
.
labels
).
to
match_array
(
labels
)
expect
(
note
.
noteable
.
assignee
).
to
eq
(
assignee
)
expect
(
note
.
noteable
.
assignee
s
).
to
eq
([
assignee
]
)
expect
(
note
.
noteable
.
milestone
).
to
eq
(
milestone
)
end
end
...
...
spec/services/slash_commands/interpret_service_spec.rb
View file @
bd65eabe
...
...
@@ -42,23 +42,6 @@ describe SlashCommands::InterpretService, services: true do
end
end
shared_examples
'assign command'
do
it
'fetches assignee and populates assignee_id if content contains /assign'
do
_
,
updates
=
service
.
execute
(
content
,
issuable
)
expect
(
updates
).
to
eq
(
assignee_id:
developer
.
id
)
end
end
shared_examples
'unassign command'
do
it
'populates assignee_id: nil if content contains /unassign'
do
issuable
.
update
(
assignee_id:
developer
.
id
)
_
,
updates
=
service
.
execute
(
content
,
issuable
)
expect
(
updates
).
to
eq
(
assignee_id:
nil
)
end
end
shared_examples
'milestone command'
do
it
'fetches milestone and populates milestone_id if content contains /milestone'
do
milestone
# populate the milestone
...
...
@@ -385,14 +368,24 @@ describe SlashCommands::InterpretService, services: true do
let
(
:issuable
)
{
issue
}
end
it_behaves_like
'assign command'
do
context
'assign command'
do
let
(
:content
)
{
"/assign @
#{
developer
.
username
}
"
}
let
(
:issuable
)
{
issue
}
end
it_behaves_like
'assign command'
do
let
(
:content
)
{
"/assign @
#{
developer
.
username
}
"
}
let
(
:issuable
)
{
merge_request
}
context
'Issue'
do
it
'fetches assignee and populates assignee_id if content contains /assign'
do
_
,
updates
=
service
.
execute
(
content
,
issue
)
expect
(
updates
).
to
eq
(
assignee_ids:
[
developer
.
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
...
...
@@ -405,14 +398,26 @@ describe SlashCommands::InterpretService, services: true do
let
(
:issuable
)
{
issue
}
end
it_behaves_like
'unassign command'
do
context
'unassign command'
do
let
(
:content
)
{
'/unassign'
}
let
(
:issuable
)
{
issue
}
end
it_behaves_like
'unassign command'
do
let
(
:content
)
{
'/unassign'
}
let
(
:issuable
)
{
merge_request
}
context
'Issue'
do
it
'populates assignee_ids: [] if content contains /unassign'
do
issue
.
update
(
assignee_ids:
[
developer
.
id
])
_
,
updates
=
service
.
execute
(
content
,
issue
)
expect
(
updates
).
to
eq
(
assignee_ids:
[])
end
end
context
'Merge Request'
do
it
'populates assignee_id: nil if content contains /unassign'
do
merge_request
.
update
(
assignee_id:
developer
.
id
)
_
,
updates
=
service
.
execute
(
content
,
merge_request
)
expect
(
updates
).
to
eq
(
assignee_id:
nil
)
end
end
end
it_behaves_like
'milestone command'
do
...
...
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