summaryrefslogtreecommitdiff
path: root/spec/requests
diff options
context:
space:
mode:
authorRebeca Méndez <scullymb@gmail.com>2016-08-29 17:23:40 +0200
committerRebeca Méndez <scullymb@gmail.com>2016-11-12 10:00:39 +0100
commit5c966f70fb218d6f4de0f888733604293f36c33e (patch)
treeecb15585624aaa4c266345e5e65d447f474b817a /spec/requests
parent6eeff67c6e03233d4480a55d05d4e0f1a88aef4c (diff)
downloadgitlab-ce-5c966f70fb218d6f4de0f888733604293f36c33e.tar.gz
Issue #4270: Recursive option for files through API
Diffstat (limited to 'spec/requests')
-rw-r--r--spec/requests/api/repositories_spec.rb35
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)