Commit fd232084 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge pull request #1650 from NARKOZ/api

API for project snippets listing
parents 5501955d 61f12da3
master
- [API] add project snippets list
- [API] allow to authorize using private token in HTTP header
- [API] add user creation
v 2.9.1
- Fixed resque custom config init
......
## List snippets
Not implemented.
Get a list of project snippets.
```
GET /projects/:id/snippets
```
Parameters:
+ `id` (required) - The ID or code name of a project
## Single snippet
......
......@@ -176,7 +176,6 @@ module Gitlab
authorize! :admin_project, user_project
@hook = user_project.hooks.find(params[:hook_id])
@hook.destroy
nil
end
# Get a project repository branches
......@@ -229,6 +228,16 @@ module Gitlab
present CommitDecorator.decorate(commits), with: Entities::RepoCommit
end
# Get a project snippets
#
# Parameters:
# id (required) - The ID or code name of a project
# Example Request:
# GET /projects/:id/snippets
get ":id/snippets" do
present paginate(user_project.snippets), with: Entities::ProjectSnippet
end
# Get a project snippet
#
# Parameters:
......
......@@ -220,6 +220,15 @@ describe Gitlab::API do
end
end
describe "GET /projects/:id/snippets" do
it "should return a project snippet" do
get api("/projects/#{project.code}/snippets", user)
response.status.should == 200
json_response.should be_an Array
json_response.first['title'].should == snippet.title
end
end
describe "GET /projects/:id/snippets/:snippet_id" do
it "should return a project snippet" do
get api("/projects/#{project.code}/snippets/#{snippet.id}", user)
......
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