Permalink
Browse files

API: add project snippets listing

  • Loading branch information...
1 parent ad5b5d1 commit 61f12da3a5b84670a0fc8cb5dbb962a365895097 @NARKOZ NARKOZ committed Oct 8, 2012
Showing with 29 additions and 1 deletion.
  1. +1 −0 CHANGELOG
  2. +9 −1 doc/api/snippets.md
  3. +10 −0 lib/api/projects.rb
  4. +9 −0 spec/requests/api/projects_spec.rb
View
@@ -1,4 +1,5 @@
master
+ - [API] add project snippets list
- [API] allow to authorize using private token in HTTP header
- [API] add user creation
View
@@ -1,6 +1,14 @@
## 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
View
@@ -228,6 +228,16 @@ class Projects < Grape::API
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 @@
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)

0 comments on commit 61f12da

Please sign in to comment.