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
ad2743df
Commit
ad2743df
authored
Jul 03, 2020
by
Justin Sleep
Committed by
Rémy Coutable
Jul 03, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix archived parameter for Group API's projects endpoint
parent
dba80652
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
48 additions
and
11 deletions
+48
-11
changelogs/unreleased/fix-group-api-archived.yml
changelogs/unreleased/fix-group-api-archived.yml
+5
-0
lib/api/groups.rb
lib/api/groups.rb
+2
-2
spec/requests/api/groups_spec.rb
spec/requests/api/groups_spec.rb
+41
-9
No files found.
changelogs/unreleased/fix-group-api-archived.yml
0 → 100644
View file @
ad2743df
---
title
:
Remove default "archived" parameter value from Groups API's projects endpoint
merge_request
:
34018
author
:
Justin Sleep
type
:
fixed
lib/api/groups.rb
View file @
ad2743df
...
...
@@ -218,7 +218,7 @@ module API
success
Entities
::
Project
end
params
do
optional
:archived
,
type:
Boolean
,
de
fault:
false
,
de
sc:
'Limit by archived status'
optional
:archived
,
type:
Boolean
,
desc:
'Limit by archived status'
optional
:visibility
,
type:
String
,
values:
Gitlab
::
VisibilityLevel
.
string_values
,
desc:
'Limit by visibility'
optional
:search
,
type:
String
,
desc:
'Return list of authorized projects matching the search criteria'
...
...
@@ -255,7 +255,7 @@ module API
success
Entities
::
Project
end
params
do
optional
:archived
,
type:
Boolean
,
de
fault:
false
,
de
sc:
'Limit by archived status'
optional
:archived
,
type:
Boolean
,
desc:
'Limit by archived status'
optional
:visibility
,
type:
String
,
values:
Gitlab
::
VisibilityLevel
.
string_values
,
desc:
'Limit by visibility'
optional
:search
,
type:
String
,
desc:
'Return list of authorized projects matching the search criteria'
...
...
spec/requests/api/groups_spec.rb
View file @
ad2743df
...
...
@@ -15,6 +15,7 @@ RSpec.describe API::Groups do
let_it_be
(
:project1
)
{
create
(
:project
,
namespace:
group1
)
}
let_it_be
(
:project2
)
{
create
(
:project
,
namespace:
group2
)
}
let_it_be
(
:project3
)
{
create
(
:project
,
namespace:
group1
,
path:
'test'
,
visibility_level:
Gitlab
::
VisibilityLevel
::
PRIVATE
)
}
let_it_be
(
:archived_project
)
{
create
(
:project
,
namespace:
group1
,
archived:
true
)
}
before
do
group1
.
add_owner
(
user1
)
...
...
@@ -471,7 +472,7 @@ RSpec.describe API::Groups do
expect
(
json_response
[
'shared_with_groups'
][
0
][
'group_access_level'
]).
to
eq
(
link
.
group_access
)
expect
(
json_response
[
'shared_with_groups'
][
0
]).
to
have_key
(
'expires_at'
)
expect
(
json_response
[
'projects'
]).
to
be_an
Array
expect
(
json_response
[
'projects'
].
length
).
to
eq
(
2
)
expect
(
json_response
[
'projects'
].
length
).
to
eq
(
3
)
expect
(
json_response
[
'shared_projects'
]).
to
be_an
Array
expect
(
json_response
[
'shared_projects'
].
length
).
to
eq
(
1
)
expect
(
json_response
[
'shared_projects'
][
0
][
'id'
]).
to
eq
(
project
.
id
)
...
...
@@ -696,7 +697,7 @@ RSpec.describe API::Groups do
expect
(
json_response
[
'parent_id'
]).
to
eq
(
nil
)
expect
(
json_response
[
'created_at'
]).
to
be_present
expect
(
json_response
[
'projects'
]).
to
be_an
Array
expect
(
json_response
[
'projects'
].
length
).
to
eq
(
2
)
expect
(
json_response
[
'projects'
].
length
).
to
eq
(
3
)
expect
(
json_response
[
'shared_projects'
]).
to
be_an
Array
expect
(
json_response
[
'shared_projects'
].
length
).
to
eq
(
0
)
expect
(
json_response
[
'default_branch_protection'
]).
to
eq
(
::
Gitlab
::
Access
::
MAINTAINER_PROJECT_ACCESS
)
...
...
@@ -822,20 +823,51 @@ RSpec.describe API::Groups do
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
.
length
).
to
eq
(
2
)
expect
(
json_response
.
length
).
to
eq
(
3
)
project_names
=
json_response
.
map
{
|
proj
|
proj
[
'name'
]
}
expect
(
project_names
).
to
match_array
([
project1
.
name
,
project3
.
name
])
expect
(
project_names
).
to
match_array
([
project1
.
name
,
project3
.
name
,
archived_project
.
name
])
expect
(
json_response
.
first
[
'visibility'
]).
to
be_present
end
context
'and using archived'
do
it
"returns the group's archived projects"
do
get
api
(
"/groups/
#{
group1
.
id
}
/projects?archived=true"
,
user1
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
length
).
to
eq
(
Project
.
public_or_visible_to_user
(
user1
).
where
(
archived:
true
).
size
)
expect
(
json_response
.
map
{
|
project
|
project
[
'id'
]
}).
to
include
(
archived_project
.
id
)
end
it
"returns the group's non-archived projects"
do
get
api
(
"/groups/
#{
group1
.
id
}
/projects?archived=false"
,
user1
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
length
).
to
eq
(
Project
.
public_or_visible_to_user
(
user1
).
where
(
archived:
false
).
size
)
expect
(
json_response
.
map
{
|
project
|
project
[
'id'
]
}).
not_to
include
(
archived_project
.
id
)
end
it
"returns all of the group's projects"
do
get
api
(
"/groups/
#{
group1
.
id
}
/projects"
,
user1
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
map
{
|
project
|
project
[
'id'
]
}).
to
contain_exactly
(
*
Project
.
public_or_visible_to_user
(
user1
).
pluck
(
:id
))
end
end
it
"returns the group's projects with simple representation"
do
get
api
(
"/groups/
#{
group1
.
id
}
/projects"
,
user1
),
params:
{
simple:
true
}
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
.
length
).
to
eq
(
2
)
expect
(
json_response
.
length
).
to
eq
(
3
)
project_names
=
json_response
.
map
{
|
proj
|
proj
[
'name'
]
}
expect
(
project_names
).
to
match_array
([
project1
.
name
,
project3
.
name
])
expect
(
project_names
).
to
match_array
([
project1
.
name
,
project3
.
name
,
archived_project
.
name
])
expect
(
json_response
.
first
[
'visibility'
]).
not_to
be_present
end
...
...
@@ -861,7 +893,7 @@ RSpec.describe API::Groups do
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
(
Array
)
expect
(
json_response
.
length
).
to
eq
(
2
)
expect
(
json_response
.
length
).
to
eq
(
3
)
end
it
"returns projects including those in subgroups"
do
...
...
@@ -874,7 +906,7 @@ RSpec.describe API::Groups do
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
(
Array
)
expect
(
json_response
.
length
).
to
eq
(
4
)
expect
(
json_response
.
length
).
to
eq
(
5
)
end
it
"does not return a non existing group"
do
...
...
@@ -959,7 +991,7 @@ RSpec.describe API::Groups do
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
include_pagination_headers
project_names
=
json_response
.
map
{
|
proj
|
proj
[
'name'
]
}
expect
(
project_names
).
to
match_array
([
project1
.
name
,
project3
.
name
])
expect
(
project_names
).
to
match_array
([
project1
.
name
,
project3
.
name
,
archived_project
.
name
])
end
it
'does not return a non existing group'
do
...
...
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