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
Jérome Perrin
gitlab-ce
Commits
1644276b
Commit
1644276b
authored
Sep 27, 2016
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add tests to LabelsFinder
parent
e00c739f
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
69 additions
and
0 deletions
+69
-0
spec/finders/labels_finder_spec.rb
spec/finders/labels_finder_spec.rb
+69
-0
No files found.
spec/finders/labels_finder_spec.rb
0 → 100644
View file @
1644276b
require
'spec_helper'
describe
LabelsFinder
do
describe
'#execute'
do
let
(
:group_1
)
{
create
(
:group
)
}
let
(
:group_2
)
{
create
(
:group
)
}
let
(
:group_3
)
{
create
(
:group
)
}
let
(
:project_1
)
{
create
(
:empty_project
,
namespace:
group_1
)
}
let
(
:project_2
)
{
create
(
:empty_project
,
namespace:
group_2
)
}
let
(
:project_3
)
{
create
(
:empty_project
)
}
let
(
:project_4
)
{
create
(
:empty_project
,
:public
)
}
let
(
:project_5
)
{
create
(
:empty_project
,
namespace:
group_1
)
}
let!
(
:project_label_1
)
{
create
(
:label
,
project:
project_1
,
title:
'Label 1'
)
}
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_5
)
{
create
(
:label
,
project:
project_5
,
title:
'Label 5'
)
}
let!
(
:group_label_1
)
{
create
(
:group_label
,
group:
group_1
,
title:
'Label 1'
)
}
let!
(
:group_label_2
)
{
create
(
:group_label
,
group:
group_1
,
title:
'Group Label 2'
)
}
let!
(
:group_label_3
)
{
create
(
:group_label
,
group:
group_2
,
title:
'Group Label 3'
)
}
let
(
:user
)
{
create
(
:user
)
}
before
do
create
(
:label
,
project:
project_3
,
title:
'Label 3'
)
create
(
:group_label
,
group:
group_3
,
title:
'Group Label 4'
)
project_1
.
team
<<
[
user
,
:developer
]
end
context
'with no filter'
do
it
'returns labels from projects the user have access'
do
group_2
.
add_developer
(
user
)
finder
=
described_class
.
new
(
user
)
expect
(
finder
.
execute
).
to
eq
[
group_label_2
,
group_label_3
,
project_label_1
,
group_label_1
,
project_label_2
,
project_label_4
]
end
end
context
'filtering by group_id'
do
it
'returns labels available for any project within the group'
do
group_1
.
add_developer
(
user
)
finder
=
described_class
.
new
(
user
,
group_id:
group_1
.
id
)
expect
(
finder
.
execute
).
to
eq
[
group_label_2
,
project_label_1
,
group_label_1
,
project_label_5
]
end
end
context
'filtering by project_id'
do
it
'returns labels available for the project'
do
finder
=
described_class
.
new
(
user
,
project_id:
project_1
.
id
)
expect
(
finder
.
execute
).
to
eq
[
group_label_2
,
project_label_1
,
group_label_1
]
end
end
context
'filtering by title'
do
it
'returns label with that title'
do
finder
=
described_class
.
new
(
user
,
title:
'Group Label 2'
)
expect
(
finder
.
execute
).
to
eq
[
group_label_2
]
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