Commit fd2320849f07071258ec045b414fe2baa0dea9da
Exists in
master
and in
4 other branches
Merge pull request #1650 from NARKOZ/api
API for project snippets listing
Showing
4 changed files
with
36 additions
and
5 deletions
Show diff stats
CHANGELOG
1 | +master | ||
2 | + - [API] add project snippets list | ||
3 | + - [API] allow to authorize using private token in HTTP header | ||
4 | + - [API] add user creation | ||
5 | + | ||
1 | v 2.9.1 | 6 | v 2.9.1 |
2 | - Fixed resque custom config init | 7 | - Fixed resque custom config init |
3 | 8 | ||
@@ -9,7 +14,7 @@ v 2.9.0 | @@ -9,7 +14,7 @@ v 2.9.0 | ||
9 | - restyled projects list on dashboard | 14 | - restyled projects list on dashboard |
10 | - ssh keys validation to prevent gitolite crash | 15 | - ssh keys validation to prevent gitolite crash |
11 | - send notifications if changed premission in project | 16 | - send notifications if changed premission in project |
12 | - - scss refactoring. gitlab_bootstrap/ dir | 17 | + - scss refactoring. gitlab_bootstrap/ dir |
13 | - fix git push http body bigger than 112k problem | 18 | - fix git push http body bigger than 112k problem |
14 | - list of labels page under issues tab | 19 | - list of labels page under issues tab |
15 | - API for milestones, keys | 20 | - API for milestones, keys |
@@ -113,7 +118,7 @@ v 2.1.0 | @@ -113,7 +118,7 @@ v 2.1.0 | ||
113 | v 2.0.0 | 118 | v 2.0.0 |
114 | - gitolite as main git host system | 119 | - gitolite as main git host system |
115 | - merge requests | 120 | - merge requests |
116 | - - project/repo access | 121 | + - project/repo access |
117 | - link to commit/issue feed | 122 | - link to commit/issue feed |
118 | - design tab | 123 | - design tab |
119 | - improved email notifications | 124 | - improved email notifications |
@@ -147,7 +152,7 @@ v 1.1.0 | @@ -147,7 +152,7 @@ v 1.1.0 | ||
147 | - bugfix & code cleaning | 152 | - bugfix & code cleaning |
148 | 153 | ||
149 | v 1.0.2 | 154 | v 1.0.2 |
150 | - - fixed bug with empty project | 155 | + - fixed bug with empty project |
151 | - added adv validation for project path & code | 156 | - added adv validation for project path & code |
152 | - feature: issues can be sortable | 157 | - feature: issues can be sortable |
153 | - bugfix | 158 | - bugfix |
doc/api/snippets.md
lib/api/projects.rb
@@ -176,7 +176,6 @@ module Gitlab | @@ -176,7 +176,6 @@ module Gitlab | ||
176 | authorize! :admin_project, user_project | 176 | authorize! :admin_project, user_project |
177 | @hook = user_project.hooks.find(params[:hook_id]) | 177 | @hook = user_project.hooks.find(params[:hook_id]) |
178 | @hook.destroy | 178 | @hook.destroy |
179 | - nil | ||
180 | end | 179 | end |
181 | 180 | ||
182 | # Get a project repository branches | 181 | # Get a project repository branches |
@@ -229,6 +228,16 @@ module Gitlab | @@ -229,6 +228,16 @@ module Gitlab | ||
229 | present CommitDecorator.decorate(commits), with: Entities::RepoCommit | 228 | present CommitDecorator.decorate(commits), with: Entities::RepoCommit |
230 | end | 229 | end |
231 | 230 | ||
231 | + # Get a project snippets | ||
232 | + # | ||
233 | + # Parameters: | ||
234 | + # id (required) - The ID or code name of a project | ||
235 | + # Example Request: | ||
236 | + # GET /projects/:id/snippets | ||
237 | + get ":id/snippets" do | ||
238 | + present paginate(user_project.snippets), with: Entities::ProjectSnippet | ||
239 | + end | ||
240 | + | ||
232 | # Get a project snippet | 241 | # Get a project snippet |
233 | # | 242 | # |
234 | # Parameters: | 243 | # Parameters: |
spec/requests/api/projects_spec.rb
@@ -220,6 +220,15 @@ describe Gitlab::API do | @@ -220,6 +220,15 @@ describe Gitlab::API do | ||
220 | end | 220 | end |
221 | end | 221 | end |
222 | 222 | ||
223 | + describe "GET /projects/:id/snippets" do | ||
224 | + it "should return a project snippet" do | ||
225 | + get api("/projects/#{project.code}/snippets", user) | ||
226 | + response.status.should == 200 | ||
227 | + json_response.should be_an Array | ||
228 | + json_response.first['title'].should == snippet.title | ||
229 | + end | ||
230 | + end | ||
231 | + | ||
223 | describe "GET /projects/:id/snippets/:snippet_id" do | 232 | describe "GET /projects/:id/snippets/:snippet_id" do |
224 | it "should return a project snippet" do | 233 | it "should return a project snippet" do |
225 | get api("/projects/#{project.code}/snippets/#{snippet.id}", user) | 234 | get api("/projects/#{project.code}/snippets/#{snippet.id}", user) |