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
4996876e
Commit
4996876e
authored
Jul 23, 2018
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add specs for label search backend code
Signed-off-by:
Dmitriy Zaporozhets
<
dmitriy.zaporozhets@gmail.com
>
parent
cb328517
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
1 deletion
+31
-1
spec/finders/labels_finder_spec.rb
spec/finders/labels_finder_spec.rb
+15
-1
spec/models/label_spec.rb
spec/models/label_spec.rb
+16
-0
No files found.
spec/finders/labels_finder_spec.rb
View file @
4996876e
...
@@ -14,7 +14,7 @@ describe LabelsFinder do
...
@@ -14,7 +14,7 @@ describe LabelsFinder do
let
(
:project_4
)
{
create
(
:project
,
:public
)
}
let
(
:project_4
)
{
create
(
:project
,
:public
)
}
let
(
:project_5
)
{
create
(
:project
,
namespace:
group_1
)
}
let
(
:project_5
)
{
create
(
:project
,
namespace:
group_1
)
}
let!
(
:project_label_1
)
{
create
(
:label
,
project:
project_1
,
title:
'Label 1'
)
}
let!
(
:project_label_1
)
{
create
(
:label
,
project:
project_1
,
title:
'Label 1'
,
description:
'awesome label'
)
}
let!
(
:project_label_2
)
{
create
(
:label
,
project:
project_2
,
title:
'Label 2'
)
}
let!
(
:project_label_2
)
{
create
(
:label
,
project:
project_2
,
title:
'Label 2'
)
}
let!
(
:project_label_4
)
{
create
(
:label
,
project:
project_4
,
title:
'Label 4'
)
}
let!
(
:project_label_4
)
{
create
(
:label
,
project:
project_4
,
title:
'Label 4'
)
}
let!
(
:project_label_5
)
{
create
(
:label
,
project:
project_5
,
title:
'Label 5'
)
}
let!
(
:project_label_5
)
{
create
(
:label
,
project:
project_5
,
title:
'Label 5'
)
}
...
@@ -196,5 +196,19 @@ describe LabelsFinder do
...
@@ -196,5 +196,19 @@ describe LabelsFinder do
expect
(
finder
.
execute
).
to
be_empty
expect
(
finder
.
execute
).
to
be_empty
end
end
end
end
context
'search by title and description'
do
it
'returns labels with a partially matching title'
do
finder
=
described_class
.
new
(
user
,
search:
'(group)'
)
expect
(
finder
.
execute
).
to
eq
[
group_label_1
]
end
it
'returns labels with a partially matching description'
do
finder
=
described_class
.
new
(
user
,
search:
'awesome'
)
expect
(
finder
.
execute
).
to
eq
[
project_label_1
]
end
end
end
end
end
end
spec/models/label_spec.rb
View file @
4996876e
...
@@ -139,4 +139,20 @@ describe Label do
...
@@ -139,4 +139,20 @@ describe Label do
end
end
end
end
end
end
describe
'.search'
do
let
(
:label
)
{
create
(
:label
,
title:
'bug'
,
description:
'incorrect behavior'
)
}
it
'returns labels with a partially matching title'
do
expect
(
described_class
.
search
(
label
.
title
[
0
..
2
])).
to
eq
([
label
])
end
it
'returns labels with a partially matching description'
do
expect
(
described_class
.
search
(
label
.
description
[
0
..
5
])).
to
eq
([
label
])
end
it
'returns nothing'
do
expect
(
described_class
.
search
(
'feature'
)).
to
be_empty
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