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

Fetch only current user projects

parent 76f5865d
......@@ -1092,16 +1092,13 @@ module API
end
module Github
class User < Grape::Entity
expose :id
expose :login do |project|
project.namespace.name
end
class Namespace < Grape::Entity
expose :path, as: :login
end
class Repository < Grape::Entity
expose :id
expose :owner, using: User, unless: -> (project, options) { project.group }
expose :namespace, as: :owner, using: Namespace
expose :name
end
......
......@@ -16,10 +16,8 @@ module API
end
resource :users do
get ':username/repos' do
projects = ProjectsFinder.new(current_user: current_user, params: project_finder_params).execute
present paginate(projects), with: ::API::Entities::Github::Repository
get ':namespace/repos' do
present paginate(current_user.authorized_projects), with: ::API::Entities::Github::Repository
end
end
......
......@@ -26,7 +26,7 @@ describe API::V3::GithubRepos do
expect(json_response).to be_an(Array)
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')
expect(json_response.first['owner'].keys).to contain_exactly('login')
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