Commit b5af4fb1 authored by Oswaldo Ferreira's avatar Oswaldo Ferreira

Allow importing groups projects

parent 8dc91cde
...@@ -1092,13 +1092,13 @@ module API ...@@ -1092,13 +1092,13 @@ module API
end end
module Github module Github
class User < Grape::Entity class Namespace < Grape::Entity
expose :username expose :path, as: :login
end end
class Repository < Grape::Entity class Repository < Grape::Entity
expose :id expose :id
expose :owner, using: User expose :namespace, as: :owner, using: Namespace
expose :name expose :name
end end
......
...@@ -40,13 +40,21 @@ describe API::V3::GithubRepos do ...@@ -40,13 +40,21 @@ describe API::V3::GithubRepos do
describe 'GET /users/:id/repos' do describe 'GET /users/:id/repos' do
context 'authenticated' do context 'authenticated' do
it 'returns an array of projects with github format' do it 'returns an array of projects with github format' do
group = create(:group)
create(:project, group: group)
group.add_master(user)
get v3_api("/users/whatever/repos", user) get v3_api("/users/whatever/repos", user)
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
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(2)
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') expect(json_response.first['owner'].keys).to contain_exactly('login')
expect(json_response.second.keys).to contain_exactly('id', 'owner', 'name')
expect(json_response.second['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