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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gitlab-ce
Commits
73af33e4
Commit
73af33e4
authored
Dec 25, 2013
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve FilterContext tests
Signed-off-by:
Dmitriy Zaporozhets
<
dmitriy.zaporozhets@gmail.com
>
parent
34f994b7
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
26 deletions
+32
-26
spec/contexts/filter_context_spec.rb
spec/contexts/filter_context_spec.rb
+32
-26
No files found.
spec/contexts/filter_context_spec.rb
View file @
73af33e4
require
'spec_helper'
describe
FilterContext
do
let
(
:user
)
{
create
:user
}
let
(
:user2
)
{
create
:user
}
let
(
:project1
)
{
create
(
:project
,
creator_id:
user
.
id
)
}
let
(
:project2
)
{
create
(
:project
,
creator_id:
user
.
id
)
}
let
(
:merge_request1
)
{
create
(
:merge_request
,
author_id:
user
.
id
,
source_project:
project1
,
target_project:
project2
)
}
let
(
:merge_request2
)
{
create
(
:merge_request
,
author_id:
user
.
id
,
source_project:
project2
,
target_project:
project1
)
}
let
(
:merge_request3
)
{
create
(
:merge_request
,
author_id:
user
.
id
,
source_project:
project2
,
target_project:
project2
)
}
let
(
:merge_request4
)
{
create
(
:merge_request
,
author_id:
user2
.
id
,
source_project:
project2
,
target_project:
project2
,
target_branch
:"notes_refactoring"
)
}
let
(
:issue1
)
{
create
(
:issue
,
assignee_id:
user
.
id
,
project:
project1
)
}
let
(
:issue2
)
{
create
(
:issue
,
assignee_id:
user
.
id
,
project:
project2
)
}
let
(
:issue3
)
{
create
(
:issue
,
assignee_id:
user2
.
id
,
project:
project2
)
}
let
(
:project1
)
{
create
(
:project
)
}
let
(
:project2
)
{
create
(
:project
)
}
let
(
:merge_request1
)
{
create
(
:merge_request
,
author:
user
,
source_project:
project1
,
target_project:
project2
)
}
let
(
:merge_request2
)
{
create
(
:merge_request
,
author:
user
,
source_project:
project2
,
target_project:
project1
)
}
let
(
:merge_request3
)
{
create
(
:merge_request
,
author:
user
,
source_project:
project2
,
target_project:
project2
)
}
let
(
:issue1
)
{
create
(
:issue
,
assignee:
user
,
project:
project1
)
}
let
(
:issue2
)
{
create
(
:issue
,
assignee:
user
,
project:
project2
)
}
let
(
:issue3
)
{
create
(
:issue
,
assignee:
user2
,
project:
project2
)
}
before
do
project1
.
team
<<
[
user
,
:master
]
project2
.
team
<<
[
user
,
:developer
]
end
describe
'merge requests'
do
before
:each
do
merge_request1
merge_request2
merge_request3
merge_request4
end
it
'should by default filter properly'
do
merge_requests
=
user
.
cared_merge_requests
params
=
{}
merge_requests
=
FilterContext
.
new
(
merge_requests
,
params
).
execute
it
'should filter by scope'
do
params
=
{
scope:
'authored'
}
merge_requests
=
FilterContext
.
new
(
MergeRequest
,
user
,
params
).
execute
merge_requests
.
size
.
should
==
3
end
it
'should apply blocks passed in on creation to the filters'
do
merge_requests
=
user
.
cared_merge_requests
params
=
{
:project_id
=>
project1
.
id
}
merge_requests
=
FilterContext
.
new
(
merge_requests
,
params
).
execute
it
'should filter by project'
do
params
=
{
project_id:
project1
.
id
,
scope:
'authored'
}
merge_requests
=
FilterContext
.
new
(
MergeRequest
,
user
,
params
).
execute
merge_requests
.
size
.
should
==
1
end
end
...
...
@@ -43,16 +43,22 @@ describe FilterContext do
issue2
issue3
end
it
'should by default filter projects properly'
do
issues
=
user
.
assigned_issues
it
'should filter by all'
do
params
=
{
scope:
"all"
}
issues
=
FilterContext
.
new
(
Issue
,
user
,
params
).
execute
issues
.
size
.
should
==
3
end
it
'should filter by assignee'
do
params
=
{}
issues
=
FilterContext
.
new
(
issues
,
params
).
execute
issues
=
FilterContext
.
new
(
Issue
,
user
,
params
).
execute
issues
.
size
.
should
==
2
end
it
'should apply blocks passed in on creation to the filters'
do
issues
=
user
.
assigned_issues
params
=
{
:project_id
=>
project1
.
id
}
issues
=
FilterContext
.
new
(
issues
,
params
).
execute
it
'should filter by project'
do
params
=
{
project_id:
project1
.
id
}
issues
=
FilterContext
.
new
(
Issue
,
user
,
params
).
execute
issues
.
size
.
should
==
1
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