diff options
author | Douwe Maan <douwe@gitlab.com> | 2016-11-15 12:15:43 +0000 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2016-11-15 12:15:43 +0000 |
commit | b3616e3074202d63a4ed03bbe94b14a4488c7800 (patch) | |
tree | 0492ad9e4b09c6a5eee90a821588a7563408b9a1 /spec | |
parent | 374b8e95c38833d6aeee491b077bd43c023c0686 (diff) | |
parent | 5c966f70fb218d6f4de0f888733604293f36c33e (diff) | |
download | gitlab-ce-b3616e3074202d63a4ed03bbe94b14a4488c7800.tar.gz |
Merge branch 'master-recursiveTree' into 'master'
Issue #4270: Recursive option for files through API
## What does this MR do?
- Adds recursive param to tree API request. With this param we can get all repository paths in a single request.
- Related [old github pull request](https://github.com/gitlabhq/gitlabhq/pull/9311)
## Are there points in the code the reviewer needs to double check?
## Why was this MR needed?
Requested in #4270
## Screenshots (if relevant)
## Does this MR meet the acceptance criteria?
- [X] [CHANGELOG](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CHANGELOG) entry added
- [X] [Documentation created/updated](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/development/doc_styleguide.md)
- [X] API support added
- Tests
- [X] Added for this feature/bug
- [x] All builds are passing
- [x] Conform by the [style guides](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CONTRIBUTING.md#style-guides)
- [x] Branch has no merge conflicts with `master` (if you do - rebase it please)
- [x] [Squashed related commits together](https://git-scm.com/book/en/Git-Tools-Rewriting-History#Squashing-Commits)
## What are the relevant issue numbers?
Requested in #4270
See merge request !6088
Diffstat (limited to 'spec')
-rw-r--r-- | spec/requests/api/repositories_spec.rb | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/spec/requests/api/repositories_spec.rb b/spec/requests/api/repositories_spec.rb index c4dc2d9006a..38c8ad34f9d 100644 --- a/spec/requests/api/repositories_spec.rb +++ b/spec/requests/api/repositories_spec.rb @@ -18,6 +18,7 @@ describe API::API, api: true do it "returns project commits" do get api("/projects/#{project.id}/repository/tree", user) + expect(response).to have_http_status(200) expect(json_response).to be_an Array @@ -43,6 +44,40 @@ describe API::API, api: true do end end + + describe 'GET /projects/:id/repository/tree?recursive=1' do + context 'authorized user' do + before { project.team << [user2, :reporter] } + + it 'should return recursive project paths tree' do + get api("/projects/#{project.id}/repository/tree?recursive=1", user) + + expect(response.status).to eq(200) + + expect(json_response).to be_an Array + expect(json_response[4]['name']).to eq('html') + expect(json_response[4]['path']).to eq('files/html') + expect(json_response[4]['type']).to eq('tree') + expect(json_response[4]['mode']).to eq('040000') + end + + it 'returns a 404 for unknown ref' do + get api("/projects/#{project.id}/repository/tree?ref_name=foo&recursive=1", user) + expect(response).to have_http_status(404) + + expect(json_response).to be_an Object + json_response['message'] == '404 Tree Not Found' + end + end + + context "unauthorized user" do + it "does not return project commits" do + get api("/projects/#{project.id}/repository/tree?recursive=1") + expect(response).to have_http_status(401) + end + end + end + describe "GET /projects/:id/repository/blobs/:sha" do it "gets the raw file contents" do get api("/projects/#{project.id}/repository/blobs/master?filepath=README.md", user) |