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
15c27fce
Commit
15c27fce
authored
Apr 05, 2017
by
Valery Sizov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Multiple issue assignees] fix spec/services/issues/create_service_spec.rb
parent
4427005b
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
160 additions
and
75 deletions
+160
-75
app/services/issues/base_service.rb
app/services/issues/base_service.rb
+1
-1
lib/gitlab/chat_commands/presenters/issue_base.rb
lib/gitlab/chat_commands/presenters/issue_base.rb
+1
-1
spec/services/issues/create_service_spec.rb
spec/services/issues/create_service_spec.rb
+76
-3
spec/services/merge_requests/create_service_spec.rb
spec/services/merge_requests/create_service_spec.rb
+81
-1
spec/support/services/issuable_create_service_shared_examples.rb
...pport/services/issuable_create_service_shared_examples.rb
+0
-52
spec/support/services/issuable_create_service_slash_commands_shared_examples.rb
...issuable_create_service_slash_commands_shared_examples.rb
+1
-17
No files found.
app/services/issues/base_service.rb
View file @
15c27fce
...
@@ -22,7 +22,7 @@ module Issues
...
@@ -22,7 +22,7 @@ module Issues
end
end
def
filter_assignee
(
issuable
)
def
filter_assignee
(
issuable
)
return
if
params
[
:assignee_ids
].
empty?
return
if
params
[
:assignee_ids
].
to_a
.
empty?
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
)}
...
...
lib/gitlab/chat_commands/presenters/issue_base.rb
View file @
15c27fce
...
@@ -22,7 +22,7 @@ module Gitlab
...
@@ -22,7 +22,7 @@ module Gitlab
[
[
{
{
title:
"Assignee"
,
title:
"Assignee"
,
value:
@resource
.
assignee
?
@resource
.
assignee
.
name
:
"_None_"
,
value:
@resource
.
assignee
s
.
any?
?
@resource
.
assignees
.
first
.
name
:
"_None_"
,
short:
true
short:
true
},
},
{
{
...
...
spec/services/issues/create_service_spec.rb
View file @
15c27fce
...
@@ -6,10 +6,10 @@ describe Issues::CreateService, services: true do
...
@@ -6,10 +6,10 @@ describe Issues::CreateService, services: true do
describe
'#execute'
do
describe
'#execute'
do
let
(
:issue
)
{
described_class
.
new
(
project
,
user
,
opts
).
execute
}
let
(
:issue
)
{
described_class
.
new
(
project
,
user
,
opts
).
execute
}
let
(
:assignee
)
{
create
(
:user
)
}
let
(
:milestone
)
{
create
(
:milestone
,
project:
project
)
}
context
'when params are valid'
do
context
'when params are valid'
do
let
(
:assignee
)
{
create
(
:user
)
}
let
(
:milestone
)
{
create
(
:milestone
,
project:
project
)
}
let
(
:labels
)
{
create_pair
(
:label
,
project:
project
)
}
let
(
:labels
)
{
create_pair
(
:label
,
project:
project
)
}
before
do
before
do
...
@@ -137,10 +137,83 @@ describe Issues::CreateService, services: true do
...
@@ -137,10 +137,83 @@ describe Issues::CreateService, services: true do
end
end
end
end
it_behaves_like
'issuable create service'
context
'issue create service'
do
context
'assignees'
do
before
{
project
.
team
<<
[
user
,
:master
]
}
it
'removes assignee when user id is invalid'
do
opts
=
{
title:
'Title'
,
description:
'Description'
,
assignee_ids:
[
-
1
]
}
issue
=
described_class
.
new
(
project
,
user
,
opts
).
execute
expect
(
issue
.
assignees
).
to
be_empty
end
it
'removes assignee when user id is 0'
do
opts
=
{
title:
'Title'
,
description:
'Description'
,
assignee_ids:
[
0
]
}
issue
=
described_class
.
new
(
project
,
user
,
opts
).
execute
expect
(
issue
.
assignees
).
to
be_empty
end
it
'saves assignee when user id is valid'
do
project
.
team
<<
[
assignee
,
:master
]
opts
=
{
title:
'Title'
,
description:
'Description'
,
assignee_ids:
[
assignee
.
id
]
}
issue
=
described_class
.
new
(
project
,
user
,
opts
).
execute
expect
(
issue
.
assignees
).
to
eq
([
assignee
])
end
context
"when issuable feature is private"
do
before
do
project
.
project_feature
.
update
(
issues_access_level:
ProjectFeature
::
PRIVATE
,
merge_requests_access_level:
ProjectFeature
::
PRIVATE
)
end
levels
=
[
Gitlab
::
VisibilityLevel
::
INTERNAL
,
Gitlab
::
VisibilityLevel
::
PUBLIC
]
levels
.
each
do
|
level
|
it
"removes not authorized assignee when project is
#{
Gitlab
::
VisibilityLevel
.
level_name
(
level
)
}
"
do
project
.
update
(
visibility_level:
level
)
opts
=
{
title:
'Title'
,
description:
'Description'
,
assignee_ids:
[
assignee
.
id
]
}
issue
=
described_class
.
new
(
project
,
user
,
opts
).
execute
expect
(
issue
.
assignees
).
to
be_empty
end
end
end
end
end
it_behaves_like
'new issuable record that supports slash commands'
it_behaves_like
'new issuable record that supports slash commands'
context
'Slash commands'
do
context
'with assignee and milestone in params and command'
do
let
(
:opts
)
do
{
assignee_ids:
[
create
(
:user
).
id
],
milestone_id:
1
,
title:
'Title'
,
description:
%(/assign @#{assignee.username}\n/milestone %"#{milestone.name}")
}
end
before
do
project
.
team
<<
[
user
,
:master
]
project
.
team
<<
[
assignee
,
:master
]
end
it
'assigns and sets milestone to issuable from command'
do
expect
(
issue
).
to
be_persisted
expect
(
issue
.
assignees
).
to
eq
([
assignee
])
expect
(
issue
.
milestone
).
to
eq
(
milestone
)
end
end
end
context
'resolving discussions'
do
context
'resolving discussions'
do
let
(
:discussion
)
{
Discussion
.
for_diff_notes
([
create
(
:diff_note_on_merge_request
)]).
first
}
let
(
:discussion
)
{
Discussion
.
for_diff_notes
([
create
(
:diff_note_on_merge_request
)]).
first
}
let
(
:merge_request
)
{
discussion
.
noteable
}
let
(
:merge_request
)
{
discussion
.
noteable
}
...
...
spec/services/merge_requests/create_service_spec.rb
View file @
15c27fce
...
@@ -84,7 +84,87 @@ describe MergeRequests::CreateService, services: true do
...
@@ -84,7 +84,87 @@ describe MergeRequests::CreateService, services: true do
end
end
end
end
it_behaves_like
'issuable create service'
context
'Slash commands'
do
context
'with assignee and milestone in params and command'
do
let
(
:merge_request
)
{
described_class
.
new
(
project
,
user
,
opts
).
execute
}
let
(
:milestone
)
{
create
(
:milestone
,
project:
project
)
}
let
(
:opts
)
do
{
assignee_id:
create
(
:user
).
id
,
milestone_id:
1
,
title:
'Title'
,
description:
%(/assign @#{assignee.username}\n/milestone %"#{milestone.name}")
,
source_branch:
'feature'
,
target_branch:
'master'
}
end
before
do
project
.
team
<<
[
user
,
:master
]
project
.
team
<<
[
assignee
,
:master
]
end
it
'assigns and sets milestone to issuable from command'
do
expect
(
merge_request
).
to
be_persisted
expect
(
merge_request
.
assignee
).
to
eq
(
assignee
)
expect
(
merge_request
.
milestone
).
to
eq
(
milestone
)
end
end
end
context
'merge request create service'
do
context
'asssignee_id'
do
let
(
:assignee
)
{
create
(
:user
)
}
before
{
project
.
team
<<
[
user
,
:master
]
}
it
'removes assignee_id when user id is invalid'
do
opts
=
{
title:
'Title'
,
description:
'Description'
,
assignee_id:
-
1
}
merge_request
=
described_class
.
new
(
project
,
user
,
opts
).
execute
expect
(
merge_request
.
assignee_id
).
to
be_nil
end
it
'removes assignee_id when user id is 0'
do
opts
=
{
title:
'Title'
,
description:
'Description'
,
assignee_id:
0
}
merge_request
=
described_class
.
new
(
project
,
user
,
opts
).
execute
expect
(
merge_request
.
assignee_id
).
to
be_nil
end
it
'saves assignee when user id is valid'
do
project
.
team
<<
[
assignee
,
:master
]
opts
=
{
title:
'Title'
,
description:
'Description'
,
assignee_id:
assignee
.
id
}
merge_request
=
described_class
.
new
(
project
,
user
,
opts
).
execute
expect
(
merge_request
.
assignee
).
to
eq
(
assignee
)
end
context
"when issuable feature is private"
do
before
do
project
.
project_feature
.
update
(
issues_access_level:
ProjectFeature
::
PRIVATE
,
merge_requests_access_level:
ProjectFeature
::
PRIVATE
)
end
levels
=
[
Gitlab
::
VisibilityLevel
::
INTERNAL
,
Gitlab
::
VisibilityLevel
::
PUBLIC
]
levels
.
each
do
|
level
|
it
"removes not authorized assignee when project is
#{
Gitlab
::
VisibilityLevel
.
level_name
(
level
)
}
"
do
project
.
update
(
visibility_level:
level
)
opts
=
{
title:
'Title'
,
description:
'Description'
,
assignee_id:
assignee
.
id
}
merge_request
=
described_class
.
new
(
project
,
user
,
opts
).
execute
expect
(
merge_request
.
assignee_id
).
to
be_nil
end
end
end
end
end
context
'while saving references to issues that the created merge request closes'
do
context
'while saving references to issues that the created merge request closes'
do
let
(
:first_issue
)
{
create
(
:issue
,
project:
project
)
}
let
(
:first_issue
)
{
create
(
:issue
,
project:
project
)
}
...
...
spec/support/services/issuable_create_service_shared_examples.rb
deleted
100644 → 0
View file @
4427005b
shared_examples
'issuable create service'
do
context
'asssignee_id'
do
let
(
:assignee
)
{
create
(
:user
)
}
before
{
project
.
team
<<
[
user
,
:master
]
}
it
'removes assignee_id when user id is invalid'
do
opts
=
{
title:
'Title'
,
description:
'Description'
,
assignee_id:
-
1
}
issuable
=
described_class
.
new
(
project
,
user
,
opts
).
execute
expect
(
issuable
.
assignee_id
).
to
be_nil
end
it
'removes assignee_id when user id is 0'
do
opts
=
{
title:
'Title'
,
description:
'Description'
,
assignee_id:
0
}
issuable
=
described_class
.
new
(
project
,
user
,
opts
).
execute
expect
(
issuable
.
assignee_id
).
to
be_nil
end
it
'saves assignee when user id is valid'
do
project
.
team
<<
[
assignee
,
:master
]
opts
=
{
title:
'Title'
,
description:
'Description'
,
assignee_id:
assignee
.
id
}
issuable
=
described_class
.
new
(
project
,
user
,
opts
).
execute
expect
(
issuable
.
assignee_id
).
to
eq
(
assignee
.
id
)
end
context
"when issuable feature is private"
do
before
do
project
.
project_feature
.
update
(
issues_access_level:
ProjectFeature
::
PRIVATE
,
merge_requests_access_level:
ProjectFeature
::
PRIVATE
)
end
levels
=
[
Gitlab
::
VisibilityLevel
::
INTERNAL
,
Gitlab
::
VisibilityLevel
::
PUBLIC
]
levels
.
each
do
|
level
|
it
"removes not authorized assignee when project is
#{
Gitlab
::
VisibilityLevel
.
level_name
(
level
)
}
"
do
project
.
update
(
visibility_level:
level
)
opts
=
{
title:
'Title'
,
description:
'Description'
,
assignee_id:
assignee
.
id
}
issuable
=
described_class
.
new
(
project
,
user
,
opts
).
execute
expect
(
issuable
.
assignee_id
).
to
be_nil
end
end
end
end
end
spec/support/services/issuable_create_service_slash_commands_shared_examples.rb
View file @
15c27fce
...
@@ -49,23 +49,7 @@ shared_examples 'new issuable record that supports slash commands' do
...
@@ -49,23 +49,7 @@ shared_examples 'new issuable record that supports slash commands' do
it
'assigns and sets milestone to issuable'
do
it
'assigns and sets milestone to issuable'
do
expect
(
issuable
).
to
be_persisted
expect
(
issuable
).
to
be_persisted
expect
(
issuable
.
assignee
).
to
eq
(
assignee
)
expect
(
issuable
.
assignees
).
to
eq
([
assignee
])
expect
(
issuable
.
milestone
).
to
eq
(
milestone
)
end
end
context
'with assignee and milestone in params and command'
do
let
(
:example_params
)
do
{
assignee:
create
(
:user
),
milestone_id:
1
,
description:
%(/assign @#{assignee.username}\n/milestone %"#{milestone.name}")
}
end
it
'assigns and sets milestone to issuable from command'
do
expect
(
issuable
).
to
be_persisted
expect
(
issuable
.
assignee
).
to
eq
(
assignee
)
expect
(
issuable
.
milestone
).
to
eq
(
milestone
)
expect
(
issuable
.
milestone
).
to
eq
(
milestone
)
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