Skip to content

Commit

Permalink
Merge pull request #56 from hassaku/project_events
Browse files Browse the repository at this point in the history
Add "Get project events" API
  • Loading branch information
NARKOZ committed Jun 3, 2014
2 parents 4a38c24 + e00d3fd commit 4b26fdd
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
15 changes: 15 additions & 0 deletions lib/gitlab/client/projects.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,21 @@ def project(id)
get("/projects/#{id}")
end

# Gets a list of project events.
#
# @example
# Gitlab.project_events(42)
# Gitlab.project_events('gitlab')
#
# @param [Integer, String] project The ID or name of a project.
# @param [Hash] options A customizable set of options.
# @option options [Integer] :page The page number.
# @option options [Integer] :per_page The number of results per page.
# @return [Array<Gitlab::ObjectifiedHash>]
def project_events(project, options={})
get("/projects/#{project}/events", :query => options)
end

# Creates a new project.
#
# @example
Expand Down
1 change: 1 addition & 0 deletions spec/fixtures/project_events.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"title":null,"project_id":2,"action_name":"opened","target_id":null,"target_type":null,"author_id":1,"data":{"before":"ac0c1aa3898d6dea54d7868ea6f9c45fd5e30c59","after":"66350dbb62a221bc619b665aef3e1e7d3b306747","ref":"refs/heads/master","user_id":1,"user_name":"Administrator","project_id":2,"repository":{"name":"gitlab-ci","url":"git@demo.gitlab.com:gitlab/gitlab-ci.git","description":"Continuous integration server for gitlabhq | Coordinator","homepage":"http://demo.gitlab.com/gitlab/gitlab-ci"},"commits":[{"id":"8cf469b039931bab37bbf025e6b69287ea3cfb0e","message":"Modify screenshot\n\nSigned-off-by: Dmitriy Zaporozhets \u003Cdummy@gmail.com\u003E","timestamp":"2014-05-20T10:34:27+00:00","url":"http://demo.gitlab.com/gitlab/gitlab-ci/commit/8cf469b039931bab37bbf025e6b69287ea3cfb0e","author":{"name":"Dummy","email":"dummy@gmail.com"}},{"id":"66350dbb62a221bc619b665aef3e1e7d3b306747","message":"Edit some code\n\nSigned-off-by: Dmitriy Zaporozhets \u003Cdummy@gmail.com\u003E","timestamp":"2014-05-20T10:35:15+00:00","url":"http://demo.gitlab.com/gitlab/gitlab-ci/commit/66350dbb62a221bc619b665aef3e1e7d3b306747","author":{"name":"Dummy","email":"dummy@gmail.com"}}],"total_commits_count":2},"target_title":null,"created_at":"2014-05-20T10:35:26.240Z"},{"title":null,"project_id":2,"action_name":"opened","target_id":2,"target_type":"MergeRequest","author_id":1,"data":null,"target_title":" Morbi et cursus leo. Sed eget vestibulum sapien","created_at":"2014-05-20T10:24:11.917Z"}]
20 changes: 20 additions & 0 deletions spec/gitlab/client/projects_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,26 @@
end
end

describe ".project_events" do
before do
stub_get("/projects/2/events", "project_events")
@events = Gitlab.project_events(2)
end

it "should get the correct resource" do
expect(a_get("/projects/2/events")).to have_been_made
end

it "should return an array of events" do
expect(@events).to be_an Array
expect(@events.size).to eq(2)
end

it "should return the action name of the event" do
expect(@events.first.action_name).to eq("opened")
end
end

describe ".create_project" do
before do
stub_post("/projects", "project")
Expand Down

0 comments on commit 4b26fdd

Please sign in to comment.