Commit 2fc55b2e authored by Oswaldo Ferreira's avatar Oswaldo Ferreira

Fetch only current user projects

parent 76f5865d
...@@ -1092,16 +1092,13 @@ module API ...@@ -1092,16 +1092,13 @@ module API
end end
module Github module Github
class User < Grape::Entity class Namespace < Grape::Entity
expose :id expose :path, as: :login
expose :login do |project|
project.namespace.name
end
end end
class Repository < Grape::Entity class Repository < Grape::Entity
expose :id expose :id
expose :owner, using: User, unless: -> (project, options) { project.group } expose :namespace, as: :owner, using: Namespace
expose :name expose :name
end end
......
...@@ -16,10 +16,8 @@ module API ...@@ -16,10 +16,8 @@ module API
end end
resource :users do resource :users do
get ':username/repos' do get ':namespace/repos' do
projects = ProjectsFinder.new(current_user: current_user, params: project_finder_params).execute present paginate(current_user.authorized_projects), with: ::API::Entities::Github::Repository
present paginate(projects), with: ::API::Entities::Github::Repository
end end
end end
......
...@@ -26,7 +26,7 @@ describe API::V3::GithubRepos do ...@@ -26,7 +26,7 @@ describe API::V3::GithubRepos do
expect(json_response).to be_an(Array) expect(json_response).to be_an(Array)
expect(json_response.size).to eq(1) expect(json_response.size).to eq(1)
expect(json_response.first.keys).to contain_exactly('id', 'owner', 'name') expect(json_response.first.keys).to contain_exactly('id', 'owner', 'name')
expect(json_response.first['owner'].keys).to contain_exactly('login', 'id') expect(json_response.first['owner'].keys).to contain_exactly('login')
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment