BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
91480e5e
Commit
91480e5e
authored
May 12, 2016
by
Sean McGivern
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Tidy up IssuesFinder specs
- Don't do setup in spec bodies. - Don't `describe` a symbol. - Don't use 'should'.
parent
78a67fc4
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
80 additions
and
68 deletions
+80
-68
issues_finder_spec.rb
spec/finders/issues_finder_spec.rb
+80
-68
No files found.
spec/finders/issues_finder_spec.rb
View file @
91480e5e
require
'spec_helper'
describe
IssuesFinder
do
let
(
:user
)
{
create
:user
}
let
(
:user2
)
{
create
:user
}
let
(
:project1
)
{
create
(
:project
)
}
let
(
:project2
)
{
create
(
:project
)
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:user2
)
{
create
(
:user
)
}
let
(
:project1
)
{
create
(
:
empty_
project
)
}
let
(
:project2
)
{
create
(
:
empty_
project
)
}
let
(
:milestone
)
{
create
(
:milestone
,
project:
project1
)
}
let
(
:label
)
{
create
(
:label
,
project:
project2
)
}
let
(
:issue1
)
{
create
(
:issue
,
author:
user
,
assignee:
user
,
project:
project1
,
milestone:
milestone
)
}
...
...
@@ -16,101 +16,113 @@ describe IssuesFinder do
project1
.
team
<<
[
user
,
:master
]
project2
.
team
<<
[
user
,
:developer
]
project2
.
team
<<
[
user2
,
:developer
]
issue1
issue2
issue3
end
describe
:execute
do
before
:each
do
issue1
issue2
issue3
end
describe
'#execute'
do
let
(
:search_user
)
{
user
}
let
(
:params
)
{
{}
}
let
(
:issues
)
{
IssuesFinder
.
new
(
search_user
,
params
.
merge
(
scope:
scope
,
state:
'opened'
)).
execute
}
context
'scope: all'
do
it
'should filter by all'
do
params
=
{
scope:
"all"
,
state:
'opened'
}
issues
=
IssuesFinder
.
new
(
user
,
params
).
execute
expect
(
issues
.
size
).
to
eq
(
3
)
end
let
(
:scope
)
{
'all'
}
it
'should filter by assignee id'
do
params
=
{
scope:
"all"
,
assignee_id:
user
.
id
,
state:
'opened'
}
issues
=
IssuesFinder
.
new
(
user
,
params
).
execute
expect
(
issues
.
size
).
to
eq
(
2
)
it
'returns all issues'
do
expect
(
issues
).
to
contain_exactly
(
issue1
,
issue2
,
issue3
)
end
it
'should filter by author id'
do
params
=
{
scope:
"all"
,
author_id:
user2
.
id
,
state:
'opened'
}
issues
=
IssuesFinder
.
new
(
user
,
params
).
execute
expect
(
issues
).
to
eq
([
issue3
])
context
'filtering by assignee ID'
do
let
(
:params
)
{
{
assignee_id:
user
.
id
}
}
it
'returns issues assigned to that user'
do
expect
(
issues
).
to
contain_exactly
(
issue1
,
issue2
)
end
end
it
'should filter by milestone id'
do
params
=
{
scope:
"all"
,
milestone_title:
milestone
.
title
,
state:
'opened'
}
issues
=
IssuesFinder
.
new
(
user
,
params
).
execute
expect
(
issues
).
to
eq
([
issue1
])
context
'filtering by author ID'
do
let
(
:params
)
{
{
author_id:
user2
.
id
}
}
it
'returns issues created by that user'
do
expect
(
issues
).
to
contain_exactly
(
issue3
)
end
end
it
'should filter by no milestone id'
do
params
=
{
scope:
"all"
,
milestone_title:
Milestone
::
None
.
title
,
state:
'opened'
}
issues
=
IssuesFinder
.
new
(
user
,
params
).
execute
expect
(
issues
).
to
match_array
([
issue2
,
issue3
])
context
'filtering by milestone'
do
let
(
:params
)
{
{
milestone_title:
milestone
.
title
}
}
it
'returns issues assigned to that milestone'
do
expect
(
issues
).
to
contain_exactly
(
issue1
)
end
end
it
'should filter by label name'
do
params
=
{
scope:
"all"
,
label_name:
label
.
title
,
state:
'opened'
}
issues
=
IssuesFinder
.
new
(
user
,
params
).
execute
expect
(
issues
).
to
eq
([
issue2
])
context
'filtering by no milestone'
do
let
(
:params
)
{
{
milestone_title:
Milestone
::
None
.
title
}
}
it
'returns issues with no milestone'
do
expect
(
issues
).
to
contain_exactly
(
issue2
,
issue3
)
end
end
it
'returns unique issues when filtering by multiple labels
'
do
l
abel2
=
create
(
:label
,
project:
project2
)
context
'filtering by label
'
do
l
et
(
:params
)
{
{
label_name:
label
.
title
}
}
create
(
:label_link
,
label:
label2
,
target:
issue2
)
it
'returns issues with that label'
do
expect
(
issues
).
to
contain_exactly
(
issue2
)
end
end
params
=
{
scope:
'all'
,
label_name:
[
label
.
title
,
label2
.
title
].
join
(
','
),
state:
'opened'
}
context
'filtering by multiple labels'
do
let
(
:params
)
{
{
label_name:
[
label
.
title
,
label2
.
title
].
join
(
','
)
}
}
let
(
:label2
)
{
create
(
:label
,
project:
project2
)
}
issues
=
IssuesFinder
.
new
(
user
,
params
).
execute
before
{
create
(
:label_link
,
label:
label2
,
target:
issue2
)
}
expect
(
issues
).
to
eq
([
issue2
])
it
'returns the unique issues with any of those labels'
do
expect
(
issues
).
to
contain_exactly
(
issue2
)
end
end
it
'should filter by no label name'
do
params
=
{
scope:
"all"
,
label_name:
Label
::
None
.
title
,
state:
'opened'
}
issues
=
IssuesFinder
.
new
(
user
,
params
).
execute
expect
(
issues
).
to
match_array
([
issue1
,
issue3
])
context
'filtering by no label'
do
let
(
:params
)
{
{
label_name:
Label
::
None
.
title
}
}
it
'returns issues with no labels'
do
expect
(
issues
).
to
contain_exactly
(
issue1
,
issue3
)
end
end
it
'should be empty for unauthorized user'
do
params
=
{
scope:
"all"
,
state:
'opened'
}
issues
=
IssuesFinder
.
new
(
nil
,
params
).
execute
expect
(
issues
.
size
).
to
be_zero
context
'when the user is unauthorized'
do
let
(
:search_user
)
{
nil
}
it
'returns no results'
do
expect
(
issues
).
to
be_empty
end
end
it
'should not include unauthorized issues'
do
params
=
{
scope:
"all"
,
state:
'opened'
}
issues
=
IssuesFinder
.
new
(
user2
,
params
).
execute
expect
(
issues
.
size
).
to
eq
(
2
)
expect
(
issues
).
not_to
include
(
issue1
)
expect
(
issues
).
to
include
(
issue2
)
expect
(
issues
).
to
include
(
issue3
)
context
'when the user can see some, but not all, issues'
do
let
(
:search_user
)
{
user2
}
it
'returns only issues they can see'
do
expect
(
issues
).
to
contain_exactly
(
issue2
,
issue3
)
end
end
end
context
'personal scope'
do
it
'should filter by assignee'
do
params
=
{
scope:
"assigned-to-me"
,
state:
'opened'
}
issues
=
IssuesFinder
.
new
(
user
,
params
).
execute
expect
(
issues
.
size
).
to
eq
(
2
)
let
(
:scope
)
{
'assigned-to-me'
}
it
'returns issue assigned to the user'
do
expect
(
issues
).
to
contain_exactly
(
issue1
,
issue
2
)
end
it
'should filter by project'
do
params
=
{
scope:
"assigned-to-me"
,
state:
'opened'
,
project_id:
project1
.
id
}
issues
=
IssuesFinder
.
new
(
user
,
params
).
execute
expect
(
issues
.
size
).
to
eq
(
1
)
context
'filtering by project'
do
let
(
:params
)
{
{
project_id:
project1
.
id
}
}
it
'returns issues assigned to the user in that project'
do
expect
(
issues
).
to
contain_exactly
(
issue1
)
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