BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
37613eaa
Commit
37613eaa
authored
May 30, 2018
by
Sean McGivern
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'bvl-group-shared-projects-private-api' into 'master'
Add `shared_projects` endpoint Closes #46800 See merge request gitlab-org/gitlab-ce!19141
parents
b703e907
df98eeab
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
92 additions
and
1 deletion
+92
-1
shared_projects_controller.rb
app/controllers/groups/shared_projects_controller.rb
+31
-0
group_child_entity.rb
app/serializers/group_child_entity.rb
+1
-1
group.rb
config/routes/group.rb
+1
-0
shared_projects_controller_spec.rb
spec/controllers/groups/shared_projects_controller_spec.rb
+59
-0
No files found.
app/controllers/groups/shared_projects_controller.rb
0 → 100644
View file @
37613eaa
module
Groups
class
SharedProjectsController
<
Groups
::
ApplicationController
respond_to
:json
before_action
:group
skip_cross_project_access_check
:index
def
index
shared_projects
=
GroupProjectsFinder
.
new
(
group:
group
,
current_user:
current_user
,
params:
finder_params
,
options:
{
only_shared:
true
}
).
execute
serializer
=
GroupChildSerializer
.
new
(
current_user:
current_user
)
.
with_pagination
(
request
,
response
)
render
json:
serializer
.
represent
(
shared_projects
)
end
private
def
finder_params
@finder_params
||=
begin
# Make the `search` param consistent for the frontend,
# which will be using `filter`.
params
[
:search
]
||=
params
[
:filter
]
if
params
[
:filter
]
params
.
permit
(
:sort
,
:search
)
end
end
end
end
app/serializers/group_child_entity.rb
View file @
37613eaa
...
...
@@ -31,7 +31,7 @@ class GroupChildEntity < Grape::Entity
end
# Project only attributes
expose
:star_count
,
expose
:star_count
,
:archived
,
if:
lambda
{
|
_instance
,
_options
|
project?
}
# Group only attributes
...
...
config/routes/group.rb
View file @
37613eaa
...
...
@@ -30,6 +30,7 @@ constraints(::Constraints::GroupUrlConstrainer.new) do
resource
:variables
,
only:
[
:show
,
:update
]
resources
:children
,
only:
[
:index
]
resources
:shared_projects
,
only:
[
:index
]
resources
:labels
,
except:
[
:show
]
do
post
:toggle_subscription
,
on: :member
...
...
spec/controllers/groups/shared_projects_controller_spec.rb
0 → 100644
View file @
37613eaa
require
'spec_helper'
describe
Groups
::
SharedProjectsController
do
def
get_shared_projects
(
params
=
{})
get
:index
,
params
.
reverse_merge
(
format: :json
,
group_id:
group
.
full_path
)
end
def
share_project
(
project
)
Projects
::
GroupLinks
::
CreateService
.
new
(
project
,
user
,
link_group_access:
ProjectGroupLink
::
DEVELOPER
).
execute
(
group
)
end
set
(
:group
)
{
create
(
:group
)
}
set
(
:user
)
{
create
(
:user
)
}
set
(
:shared_project
)
do
shared_project
=
create
(
:project
,
namespace:
user
.
namespace
)
share_project
(
shared_project
)
shared_project
end
let
(
:json_project_ids
)
{
json_response
.
map
{
|
project_info
|
project_info
[
'id'
]
}
}
before
do
sign_in
(
user
)
end
describe
'GET #index'
do
it
'returns only projects shared with the group'
do
create
(
:project
,
namespace:
group
)
get_shared_projects
expect
(
json_project_ids
).
to
contain_exactly
(
shared_project
.
id
)
end
it
'allows filtering shared projects'
do
project
=
create
(
:project
,
:archived
,
namespace:
user
.
namespace
,
name:
"Searching for"
)
share_project
(
project
)
get_shared_projects
(
filter:
'search'
)
expect
(
json_project_ids
).
to
contain_exactly
(
project
.
id
)
end
it
'allows sorting projects'
do
shared_project
.
update!
(
name:
'bbb'
)
second_project
=
create
(
:project
,
namespace:
user
.
namespace
,
name:
'aaaa'
)
share_project
(
second_project
)
get_shared_projects
(
sort:
'name_asc'
)
expect
(
json_project_ids
).
to
eq
([
second_project
.
id
,
shared_project
.
id
])
end
end
end
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