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
9fba1176
Commit
9fba1176
authored
Nov 14, 2019
by
Andreas Brandl
Committed by
Ash McKenzie
Nov 15, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add more specs for combined filters
parent
0729fbfd
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
0 deletions
+30
-0
spec/finders/projects_finder_spec.rb
spec/finders/projects_finder_spec.rb
+9
-0
spec/requests/api/projects_spec.rb
spec/requests/api/projects_spec.rb
+21
-0
No files found.
spec/finders/projects_finder_spec.rb
View file @
9fba1176
...
@@ -74,6 +74,15 @@ describe ProjectsFinder, :do_not_mock_admin_mode do
...
@@ -74,6 +74,15 @@ describe ProjectsFinder, :do_not_mock_admin_mode do
end
end
end
end
describe
'with both id_before and id_after'
do
context
'only returns projects with a project id less than given'
do
let!
(
:projects
)
{
create_list
(
:project
,
5
,
:public
)
}
let
(
:params
)
{
{
id_after:
projects
.
first
.
id
,
id_before:
projects
.
last
.
id
}}
it
{
is_expected
.
to
contain_exactly
(
*
projects
[
1
..-
2
])
}
end
end
describe
'filter by visibility_level'
do
describe
'filter by visibility_level'
do
before
do
before
do
private_project
.
add_maintainer
(
user
)
private_project
.
add_maintainer
(
user
)
...
...
spec/requests/api/projects_spec.rb
View file @
9fba1176
...
@@ -378,6 +378,14 @@ describe API::Projects do
...
@@ -378,6 +378,14 @@ describe API::Projects do
end
end
end
end
context
'and using both id_after and id_before'
do
it_behaves_like
'projects response'
do
let
(
:filter
)
{
{
id_before:
project2
.
id
,
id_after:
public_project
.
id
}
}
let
(
:current_user
)
{
user
}
let
(
:projects
)
{
[
public_project
,
project
,
project2
,
project3
].
select
{
|
p
|
p
.
id
<
project2
.
id
&&
p
.
id
>
public_project
.
id
}
}
end
end
context
'and membership=true'
do
context
'and membership=true'
do
it_behaves_like
'projects response'
do
it_behaves_like
'projects response'
do
let
(
:filter
)
{
{
membership:
true
}
}
let
(
:filter
)
{
{
membership:
true
}
}
...
@@ -908,6 +916,19 @@ describe API::Projects do
...
@@ -908,6 +916,19 @@ describe API::Projects do
end
end
end
end
context
'and using both id_before and id_after'
do
let!
(
:more_projects
)
{
create_list
(
:project
,
5
,
:public
,
creator_id:
user4
.
id
,
namespace:
user4
.
namespace
)
}
it
'only returns projects with id matching the range'
do
get
api
(
"/users/
#{
user4
.
id
}
/projects?id_after=
#{
more_projects
.
first
.
id
}
&id_before=
#{
more_projects
.
last
.
id
}
"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
map
{
|
project
|
project
[
'id'
]
}).
to
contain_exactly
(
*
more_projects
[
1
..-
2
].
map
(
&
:id
))
end
end
it
'returns projects filtered by username'
do
it
'returns projects filtered by username'
do
get
api
(
"/users/
#{
user4
.
username
}
/projects/"
,
user
)
get
api
(
"/users/
#{
user4
.
username
}
/projects/"
,
user
)
...
...
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