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
d7107d44
Commit
d7107d44
authored
Jun 21, 2018
by
Mark Chao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add spec for labels auto complete
parent
9968c60f
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
58 additions
and
0 deletions
+58
-0
ee/spec/services/groups/autocomplete_service_spec.rb
ee/spec/services/groups/autocomplete_service_spec.rb
+58
-0
No files found.
ee/spec/services/groups/autocomplete_service_spec.rb
0 → 100644
View file @
d7107d44
require
'spec_helper'
describe
Groups
::
AutocompleteService
do
let!
(
:group
)
{
create
(
:group
,
:nested
,
avatar:
fixture_file_upload
(
'spec/fixtures/dk.png'
))
}
let!
(
:sub_group
)
{
create
(
:group
,
parent:
group
)
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:epic
)
{
create
(
:epic
,
group:
group
,
author:
user
)
}
before
do
create
(
:group_member
,
group:
group
,
user:
user
)
end
def
user_to_autocompletable
(
user
)
{
username:
user
.
username
,
name:
user
.
name
,
avatar_url:
user
.
avatar_url
}
end
describe
'#labels'
do
let!
(
:label1
)
{
create
(
:group_label
,
group:
group
)
}
let!
(
:label2
)
{
create
(
:group_label
,
group:
group
)
}
let!
(
:sub_group_label
)
{
create
(
:group_label
,
group:
sub_group
)
}
let!
(
:parent_group_label
)
{
create
(
:group_label
,
group:
group
.
parent
)
}
it
'returns labels from own group and ancestor groups'
do
service
=
described_class
.
new
(
group
,
user
)
result
=
service
.
labels
expected_labels
=
[
label1
,
label2
,
parent_group_label
]
expect
(
result
.
size
).
to
eq
(
3
)
expect
(
result
.
map
(
&
:title
)).
to
contain_exactly
(
*
expected_labels
.
map
(
&
:title
))
end
context
'some labels are already assigned'
do
before
do
epic
.
labels
<<
label1
end
it
'marks already assigned as set'
do
service
=
described_class
.
new
(
group
,
user
)
result
=
service
.
labels
(
epic
)
expected_labels
=
[
label1
,
label2
,
parent_group_label
]
expect
(
result
.
size
).
to
eq
(
3
)
expect
(
result
.
map
{
|
label
|
label
[
'title'
]
}).
to
contain_exactly
(
*
expected_labels
.
map
(
&
:title
))
epic
.
labels
.
each
do
|
assigned_label
|
expect
(
result
.
find
{
|
label
|
label
[
'title'
]
==
assigned_label
.
title
}[
:set
]).
to
eq
(
true
)
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