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
044a1713
Commit
044a1713
authored
Aug 30, 2017
by
Oswaldo Ferreira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove hardcoded code from /api/v3/users/:ns/repos
parent
43095a61
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
32 deletions
+28
-32
lib/api/entities.rb
lib/api/entities.rb
+11
-9
lib/api/v3/github_repos.rb
lib/api/v3/github_repos.rb
+10
-16
spec/requests/api/v3/github_repos_spec.rb
spec/requests/api/v3/github_repos_spec.rb
+7
-7
No files found.
lib/api/entities.rb
View file @
044a1713
...
...
@@ -1091,17 +1091,19 @@ module API
expose
:total_failures
end
class
GithubRepoOwner
<
Grape
::
Entity
expose
:id
expose
:login
do
|
project
|
project
.
namespace
&
.
name
module
Github
class
GithubRepoOwner
<
Grape
::
Entity
expose
:id
expose
:login
do
|
project
|
project
.
namespace
.
name
end
end
end
class
GithubUserRepo
<
Grape
::
Entity
expose
:id
expose
:owner
,
using:
GithubRepoOwner
,
unless:
->
(
project
,
options
)
{
project
.
group
}
expose
:name
class
Repository
<
Grape
::
Entity
expose
:id
expose
:owner
,
using:
GithubRepoOwner
,
unless:
->
(
project
,
options
)
{
project
.
group
}
expose
:name
end
end
end
end
lib/api/v3/github_repos.rb
View file @
044a1713
...
...
@@ -3,23 +3,23 @@ module API
class
GithubRepos
<
Grape
::
API
before
{
authenticate!
}
desc
'Get a list of repos of a group'
resource
:orgs
do
get
':namespace/repos'
do
present
[]
end
end
resource
:user
do
get
:repos
do
present
[]
end
end
resource
:users
do
get
':namespace/repos'
do
present
[{
"id"
=>
11
,
"owner"
=>
{
"login"
=>
"oswaldo"
,
"id"
=>
1
,
},
"name"
=>
"test"
,
}]
get
':username/repos'
do
projects
=
ProjectsFinder
.
new
(
current_user:
current_user
,
params:
project_finder_params
).
execute
present
projects
,
with:
::
API
::
Entities
::
Github
::
Repository
end
end
...
...
@@ -81,12 +81,6 @@ module API
present
hash
end
end
resource
:user
do
get
:repos
do
present
[]
end
end
end
end
end
spec/requests/api/v3/github_repos_spec.rb
View file @
044a1713
...
...
@@ -2,29 +2,29 @@ require 'spec_helper'
describe
API
::
V3
::
GithubRepos
do
let
(
:user
)
{
create
(
:user
)
}
let!
(
:project
)
{
create
(
:project
,
namespace:
user
.
namespace
)
}
describe
'GET /orgs/:id/repos'
do
let
(
:current_user
)
{
user
}
it
'returns
repos with expected format
'
do
it
'returns
an array of projects
'
do
group
=
create
(
:group
)
get
v3_api
(
"/orgs/
#{
group
.
path
}
/repos"
,
current_user
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
json_response
).
to
be_empty
end
end
describe
'GET /users/:id/repos'
do
let
(
:current_user
)
{
user
}
it
'returns repos with expected format'
do
get
v3_api
(
"/users/
#{
user
.
namespace
.
path
}
/repos"
,
current_user
)
it
'returns an array of projects with github format'
do
get
v3_api
(
"/users/whatever/repos"
,
user
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
json_response
).
to
be_an
(
Array
)
expect
(
json_response
).
to
eq
(
''
)
expect
(
json_response
.
size
).
to
eq
(
1
)
expect
(
json_response
.
first
.
keys
).
to
contain_exactly
(
'id'
,
'owner'
,
'name'
)
expect
(
json_response
.
first
[
'owner'
].
keys
).
to
contain_exactly
(
'login'
,
'id'
)
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