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
2ec2a906
Commit
2ec2a906
authored
Oct 26, 2018
by
Heinrich Lee Yu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add group projects API options for including shared and subgroups
parent
08ddb655
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
1 deletion
+39
-1
lib/api/groups.rb
lib/api/groups.rb
+13
-1
spec/requests/api/groups_spec.rb
spec/requests/api/groups_spec.rb
+26
-0
No files found.
lib/api/groups.rb
View file @
2ec2a906
...
...
@@ -60,7 +60,17 @@ module API
def
find_group_projects
(
params
)
group
=
find_group!
(
params
[
:id
])
projects
=
GroupProjectsFinder
.
new
(
group:
group
,
current_user:
current_user
,
params:
project_finder_params
).
execute
options
=
{
only_owned:
!
params
[
:include_shared
],
include_subgroups:
params
[
:include_subgroups
]
}
projects
=
GroupProjectsFinder
.
new
(
group:
group
,
current_user:
current_user
,
params:
project_finder_params
,
options:
options
).
execute
projects
=
projects
.
with_issues_available_for_user
(
current_user
)
if
params
[
:with_issues_enabled
]
projects
=
projects
.
with_merge_requests_enabled
if
params
[
:with_merge_requests_enabled
]
projects
=
reorder_projects
(
projects
)
...
...
@@ -201,6 +211,8 @@ module API
optional
:starred
,
type:
Boolean
,
default:
false
,
desc:
'Limit by starred status'
optional
:with_issues_enabled
,
type:
Boolean
,
default:
false
,
desc:
'Limit by enabled issues feature'
optional
:with_merge_requests_enabled
,
type:
Boolean
,
default:
false
,
desc:
'Limit by enabled merge requests feature'
optional
:include_subgroups
,
type:
Boolean
,
default:
false
,
desc:
'Includes projects in subgroups of this group'
optional
:include_shared
,
type:
Boolean
,
default:
true
,
desc:
'Include projects shared to this group'
use
:pagination
use
:with_custom_attributes
...
...
spec/requests/api/groups_spec.rb
View file @
2ec2a906
...
...
@@ -502,6 +502,32 @@ describe API::Groups do
expect
(
json_response
.
first
[
'name'
]).
to
eq
(
public_project
.
name
)
end
it
'returns projects excluding shared'
do
create
(
:project_group_link
,
project:
create
(
:project
),
group:
group1
)
create
(
:project_group_link
,
project:
create
(
:project
),
group:
group1
)
create
(
:project_group_link
,
project:
create
(
:project
),
group:
group1
)
get
api
(
"/groups/
#{
group1
.
id
}
/projects"
,
user1
),
include_shared:
false
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
(
Array
)
expect
(
json_response
.
length
).
to
eq
(
2
)
end
it
'returns projects including those in subgroups'
do
subgroup
=
create
(
:group
,
parent:
group1
)
create
(
:project
,
group:
subgroup
)
create
(
:project
,
group:
subgroup
)
get
api
(
"/groups/
#{
group1
.
id
}
/projects"
,
user1
),
include_subgroups:
true
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
(
Array
)
expect
(
json_response
.
length
).
to
eq
(
4
)
end
it
"does not return a non existing group"
do
get
api
(
"/groups/1328/projects"
,
user1
)
...
...
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