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
0
Merge Requests
0
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
Léo-Paul Géneau
gitlab-ce
Commits
0cfe35f7
Commit
0cfe35f7
authored
May 05, 2017
by
Valery Sizov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Multiple issue assignee: CE restriction for multiple assignees
parent
9c0f2485
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
52 additions
and
0 deletions
+52
-0
app/services/issues/base_service.rb
app/services/issues/base_service.rb
+3
-0
spec/requests/api/issues_spec.rb
spec/requests/api/issues_spec.rb
+22
-0
spec/services/notes/slash_commands_service_spec.rb
spec/services/notes/slash_commands_service_spec.rb
+27
-0
No files found.
app/services/issues/base_service.rb
View file @
0cfe35f7
...
@@ -24,6 +24,9 @@ module Issues
...
@@ -24,6 +24,9 @@ module Issues
def
filter_assignee
(
issuable
)
def
filter_assignee
(
issuable
)
return
if
params
[
:assignee_ids
].
blank?
return
if
params
[
:assignee_ids
].
blank?
# The number of assignees is limited by one for GitLab CE
params
[
:assignee_ids
].
slice!
(
0
,
1
)
assignee_ids
=
params
[
:assignee_ids
].
select
{
|
assignee_id
|
assignee_can_read?
(
issuable
,
assignee_id
)
}
assignee_ids
=
params
[
:assignee_ids
].
select
{
|
assignee_id
|
assignee_can_read?
(
issuable
,
assignee_id
)
}
if
params
[
:assignee_ids
].
map
(
&
:to_s
)
==
[
IssuableFinder
::
NONE
]
if
params
[
:assignee_ids
].
map
(
&
:to_s
)
==
[
IssuableFinder
::
NONE
]
...
...
spec/requests/api/issues_spec.rb
View file @
0cfe35f7
...
@@ -772,6 +772,17 @@ describe API::Issues do
...
@@ -772,6 +772,17 @@ describe API::Issues do
end
end
end
end
context
'CE restrictions'
do
it
'creates a new project issue with no more than one assignee'
do
post
api
(
"/projects/
#{
project
.
id
}
/issues"
,
user
),
title:
'new issue'
,
assignee_ids:
[
user2
.
id
,
guest
.
id
]
expect
(
response
).
to
have_http_status
(
201
)
expect
(
json_response
[
'title'
]).
to
eq
(
'new issue'
)
expect
(
json_response
[
'assignees'
].
count
).
to
eq
(
1
)
end
end
it
'creates a new project issue'
do
it
'creates a new project issue'
do
post
api
(
"/projects/
#{
project
.
id
}
/issues"
,
user
),
post
api
(
"/projects/
#{
project
.
id
}
/issues"
,
user
),
title:
'new issue'
,
labels:
'label, label2'
,
weight:
3
,
title:
'new issue'
,
labels:
'label, label2'
,
weight:
3
,
...
@@ -1111,6 +1122,17 @@ describe API::Issues do
...
@@ -1111,6 +1122,17 @@ describe API::Issues do
expect
(
json_response
[
'assignees'
].
first
[
'name'
]).
to
eq
(
user2
.
name
)
expect
(
json_response
[
'assignees'
].
first
[
'name'
]).
to
eq
(
user2
.
name
)
end
end
context
'CE restrictions'
do
it
'updates an issue with several assignee but only one has been applied'
do
put
api
(
"/projects/
#{
project
.
id
}
/issues/
#{
issue
.
iid
}
"
,
user
),
assignee_ids:
[
user2
.
id
,
guest
.
id
]
expect
(
response
).
to
have_http_status
(
200
)
expect
(
json_response
[
'assignees'
].
size
).
to
eq
(
1
)
end
end
end
end
describe
'PUT /projects/:id/issues/:issue_iid to update labels'
do
describe
'PUT /projects/:id/issues/:issue_iid to update labels'
do
...
...
spec/services/notes/slash_commands_service_spec.rb
View file @
0cfe35f7
...
@@ -220,4 +220,31 @@ describe Notes::SlashCommandsService, services: true do
...
@@ -220,4 +220,31 @@ describe Notes::SlashCommandsService, services: true do
let
(
:note
)
{
build
(
:note_on_commit
,
project:
project
)
}
let
(
:note
)
{
build
(
:note_on_commit
,
project:
project
)
}
end
end
end
end
context
'CE restriction for issue assignees'
do
describe
'/assign'
do
let
(
:project
)
{
create
(
:empty_project
)
}
let
(
:master
)
{
create
(
:user
).
tap
{
|
u
|
project
.
team
<<
[
u
,
:master
]
}
}
let
(
:assignee
)
{
create
(
:user
)
}
let
(
:master
)
{
create
(
:user
)
}
let
(
:service
)
{
described_class
.
new
(
project
,
master
)
}
let
(
:note
)
{
create
(
:note_on_issue
,
note:
note_text
,
project:
project
)
}
let
(
:note_text
)
do
%(/assign @#{assignee.username} @#{master.username}\n")
end
before
do
project
.
team
<<
[
master
,
:master
]
project
.
team
<<
[
assignee
,
:master
]
end
it
'adds only one assignee from the list'
do
content
,
command_params
=
service
.
extract_commands
(
note
)
service
.
execute
(
command_params
,
note
)
expect
(
note
.
noteable
.
assignees
.
count
).
to
eq
(
1
)
end
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