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
Tatuya Kamada
gitlab-ce
Commits
81a12c10
Commit
81a12c10
authored
Dec 12, 2016
by
Robert Schilling
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
API: Fix groups filter
parent
ff02c63c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
1 deletion
+21
-1
lib/api/groups.rb
lib/api/groups.rb
+10
-1
spec/requests/api/groups_spec.rb
spec/requests/api/groups_spec.rb
+11
-0
No files found.
lib/api/groups.rb
View file @
81a12c10
module
API
module
API
class
Groups
<
Grape
::
API
class
Groups
<
Grape
::
API
include
PaginationParams
include
PaginationParams
before
{
authenticate!
}
before
{
authenticate!
}
helpers
do
helpers
do
...
@@ -117,11 +117,20 @@ module API
...
@@ -117,11 +117,20 @@ module API
success
Entities
::
Project
success
Entities
::
Project
end
end
params
do
params
do
optional
:archived
,
type:
Boolean
,
default:
false
,
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'
optional
:order_by
,
type:
String
,
values:
%w[id name path created_at updated_at last_activity_at]
,
default:
'created_at'
,
desc:
'Return projects ordered by field'
optional
:sort
,
type:
String
,
values:
%w[asc desc]
,
default:
'desc'
,
desc:
'Return projects sorted in ascending and descending order'
use
:pagination
use
:pagination
end
end
get
":id/projects"
do
get
":id/projects"
do
group
=
find_group!
(
params
[
:id
])
group
=
find_group!
(
params
[
:id
])
projects
=
GroupProjectsFinder
.
new
(
group
).
execute
(
current_user
)
projects
=
GroupProjectsFinder
.
new
(
group
).
execute
(
current_user
)
projects
=
filter_projects
(
projects
)
present
paginate
(
projects
),
with:
Entities
::
Project
,
user:
current_user
present
paginate
(
projects
),
with:
Entities
::
Project
,
user:
current_user
end
end
...
...
spec/requests/api/groups_spec.rb
View file @
81a12c10
...
@@ -245,6 +245,17 @@ describe API::Groups, api: true do
...
@@ -245,6 +245,17 @@ describe API::Groups, api: true do
expect
(
project_names
).
to
match_array
([
project1
.
name
,
project3
.
name
])
expect
(
project_names
).
to
match_array
([
project1
.
name
,
project3
.
name
])
end
end
it
'filters the groups projects'
do
public_projet
=
create
(
:project
,
:public
,
path:
'test1'
,
group:
group1
)
get
api
(
"/groups/
#{
group1
.
id
}
/projects"
,
user1
),
visibility:
'public'
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
[
'name'
]).
to
eq
(
public_projet
.
name
)
end
it
"does not return a non existing group"
do
it
"does not return a non existing group"
do
get
api
(
"/groups/1328/projects"
,
user1
)
get
api
(
"/groups/1328/projects"
,
user1
)
expect
(
response
).
to
have_http_status
(
404
)
expect
(
response
).
to
have_http_status
(
404
)
...
...
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