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
eda30f31
Commit
eda30f31
authored
Jun 16, 2017
by
vanadium23
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Filter archived project in API v3 only if param present
parent
043f8c26
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
39 additions
and
2 deletions
+39
-2
changelogs/unreleased/32301-filter-archive-project-on-param-present.yml
...eleased/32301-filter-archive-project-on-param-present.yml
+4
-0
lib/api/v3/helpers.rb
lib/api/v3/helpers.rb
+4
-1
lib/api/v3/projects.rb
lib/api/v3/projects.rb
+1
-1
spec/requests/api/v3/projects_spec.rb
spec/requests/api/v3/projects_spec.rb
+30
-0
No files found.
changelogs/unreleased/32301-filter-archive-project-on-param-present.yml
0 → 100644
View file @
eda30f31
---
title
:
Filter archived project in API v3 only if param present
merge_request
:
12245
author
:
Ivan Chernov
lib/api/v3/helpers.rb
View file @
eda30f31
...
...
@@ -38,7 +38,10 @@ module API
projects
=
projects
.
where
(
visibility_level:
Gitlab
::
VisibilityLevel
.
level_value
(
params
[
:visibility
]))
end
projects
=
projects
.
where
(
archived:
params
[
:archived
])
unless
params
[
:archived
].
nil?
projects
=
projects
.
where
(
archived:
to_boolean
(
params
[
:archived
]))
end
projects
.
reorder
(
params
[
:order_by
]
=>
params
[
:sort
])
end
end
...
...
lib/api/v3/projects.rb
View file @
eda30f31
...
...
@@ -69,7 +69,7 @@ module API
end
params
:filter_params
do
optional
:archived
,
type:
Boolean
,
default:
false
,
desc:
'Limit by archived status'
optional
:archived
,
type:
Boolean
,
default:
nil
,
desc:
'Limit by archived status'
optional
:visibility
,
type:
String
,
values:
%w[public internal private]
,
desc:
'Limit by visibility'
optional
:search
,
type:
String
,
desc:
'Return list of authorized projects matching the search criteria'
...
...
spec/requests/api/v3/projects_spec.rb
View file @
eda30f31
...
...
@@ -124,6 +124,36 @@ describe API::V3::Projects do
end
end
context
'and using archived'
do
let!
(
:archived_project
)
{
create
(
:empty_project
,
creator_id:
user
.
id
,
namespace:
user
.
namespace
,
archived:
true
)
}
it
'returns archived project'
do
get
v3_api
(
'/projects?archived=true'
,
user
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
length
).
to
eq
(
1
)
expect
(
json_response
.
first
[
'id'
]).
to
eq
(
archived_project
.
id
)
end
it
'returns non-archived project'
do
get
v3_api
(
'/projects?archived=false'
,
user
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
length
).
to
eq
(
1
)
expect
(
json_response
.
first
[
'id'
]).
to
eq
(
project
.
id
)
end
it
'returns all project'
do
get
v3_api
(
'/projects'
,
user
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
length
).
to
eq
(
2
)
end
end
context
'and using sorting'
do
before
do
project2
...
...
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