Skip to content

Commit

Permalink
Merge branch 'issue_events'
Browse files Browse the repository at this point in the history
* issue_events:
  List all Issue events for a Repository
  Add `issue_event` method, to get information on a specific Issue Event
  List all Issue Events
  • Loading branch information
catsby committed Nov 6, 2011
2 parents ec26abb + cdb0ecc commit 0f1d078
Show file tree
Hide file tree
Showing 7 changed files with 335 additions and 1 deletion.
30 changes: 29 additions & 1 deletion lib/octokit/client/issues.rb
Expand Up @@ -122,7 +122,7 @@ def issue_comments(repo, number, options={})
#
# @param repo [String, Repository, Hash] A GitHub repository
# @param number [String] Number ID of the issue
# @return [Array] Array of comments that belong to an issue
# @return [Comment] The specific comment in question
# @see http://developer.github.com/v3/issues/comments/#get-a-single-comment
# @example Get comments for issue #25 from pengwynn/octokit
# Octokit.issue_comments("pengwynn/octokit", "25")
Expand Down Expand Up @@ -167,6 +167,34 @@ def update_comment(repo, number, comment, options={})
def delete_comment(repo, number, options={})
delete("/repos/#{Repository.new(repo)}/issues/comments/#{number}", options, 3, true, true)
end


# List events for an Issue
#
# @param repo [String, Repository, Hash] A GitHub repository
# @param number [Integer] Issue number
#
# @return [Array] Array of events for that issue
# @see http://developer.github.com/v3/issues/events/
# @example List all issues events for issue #38 on pengwynn/octokit
# Octokit.issue_events("pengwynn/octokit", 38)
def issue_events(repo, number, options={})
get("/repos/#{Repository.new(repo)}/issues/#{number}/events", options, 3)
end

# Get information on a single Issue Event
#
# @param repo [String, Repository, Hash] A GitHub repository
# @param number [Integer] Event number
#
# @return [Event] A single Event for an Issue
# @see http://developer.github.com/v3/issues/events/#get-a-single-event
# @example Get Event information for ID 3094334 (a pull request was closed)
# Octokit.issue_event("pengwynn/octokit", 3094334)
def issue_event(repo, number, options={})
get("/repos/#{Repository.new(repo)}/issues/events/#{number}", options, 3)
end

end
end
end
14 changes: 14 additions & 0 deletions lib/octokit/client/repositories.rb
Expand Up @@ -141,6 +141,20 @@ def tags(repo, options={})
def branches(repo, options={})
get "/repos/#{Repository.new repo}/branches", options, 3
end

# Get all Issue Events for a given Repository
#
# @param repo [String, Repository, Hash] A GitHub repository
#
# @return [Array] Array of all Issue Events for this Repository
# @see http://developer.github.com/v3/issues/events/#list-events-for-a-repository
# @example Get all Issue Events for Octokit
# Octokit.repository_issue_events("pengwynn/octokit")
def repository_issue_events(repo, options={})
get "/repos/#{Repository.new repo}/issues/events", options, 3
end
alias :repo_issue_events :repository_issue_events

end
end
end
44 changes: 44 additions & 0 deletions spec/fixtures/v3/issue_event.json
@@ -0,0 +1,44 @@
{
"actor": {
"url": "https://api.github.com/users/sferik",
"gravatar_id": "1f74b13f1e5c6c69cb5d7fbaabb1e2cb",
"login": "sferik",
"avatar_url": "https://secure.gravatar.com/avatar/1f74b13f1e5c6c69cb5d7fbaabb1e2cb?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png",
"id": 10308
},
"url": "https://api.github.com/repos/pengwynn/octokit/issues/events/3094334",
"created_at": "2011-09-08T15:14:06Z",
"commit_id": null,
"event": "closed",
"issue": {
"body": "This may just be my n00bness (and I apologize if it is), but I keep getting the following error when trying to use octokit with omniauth in a Sinatra project:\r\n\r\n raise_if_conflicts': Unable to activate octokit-0.6.4, because addressable-2.2.4 conflicts with addressable (~> 2.2.6), faraday-0.6.1 conflicts with faraday (~> 0.7.3) (Gem::LoadError)`\r\n\r\nIs there a way to easily fix this? I've never run into a problem like it, and would be great if I could use the two gems together.\r\n\r\nThank you!",
"url": "https://api.github.com/repos/pengwynn/octokit/issues/54",
"created_at": "2011-09-05T03:55:21Z",
"comments": 2,
"title": "Can't use octokit with omniauth",
"html_url": "https://github.com/pengwynn/octokit/issues/54",
"closed_at": "2011-09-08T15:14:06Z",
"assignee": null,
"milestone": null,
"labels": [

],
"number": 54,
"state": "closed",
"user": {
"url": "https://api.github.com/users/connormontgomery",
"gravatar_id": "f12ed6301268a1a8d40f292135e6bfca",
"login": "connormontgomery",
"avatar_url": "https://secure.gravatar.com/avatar/f12ed6301268a1a8d40f292135e6bfca?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png",
"id": 97697
},
"pull_request": {
"html_url": null,
"diff_url": null,
"patch_url": null
},
"updated_at": "2011-09-08T15:14:06Z",
"id": 1564650
},
"id": 3094334
}
72 changes: 72 additions & 0 deletions spec/fixtures/v3/issue_events.json
@@ -0,0 +1,72 @@
[
{
"created_at": "2011-06-02T12:39:23Z",
"commit_id": null,
"event": "mentioned",
"actor": {
"url": "https://api.github.com/users/pengwynn",
"avatar_url": "https://secure.gravatar.com/avatar/7e19cd5486b5d6dc1ef90e671ba52ae0?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png",
"id": 865,
"gravatar_id": "7e19cd5486b5d6dc1ef90e671ba52ae0",
"login": "pengwynn"
},
"url": "https://api.github.com/repos/pengwynn/octokit/issues/events/972711",
"id": 972711
},
{
"created_at": "2011-06-02T12:39:23Z",
"commit_id": null,
"event": "subscribed",
"actor": {
"url": "https://api.github.com/users/pengwynn",
"avatar_url": "https://secure.gravatar.com/avatar/7e19cd5486b5d6dc1ef90e671ba52ae0?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png",
"id": 865,
"gravatar_id": "7e19cd5486b5d6dc1ef90e671ba52ae0",
"login": "pengwynn"
},
"url": "https://api.github.com/repos/pengwynn/octokit/issues/events/972712",
"id": 972712
},
{
"created_at": "2011-06-02T12:39:23Z",
"commit_id": null,
"event": "subscribed",
"actor": {
"url": "https://api.github.com/users/shock",
"avatar_url": "https://secure.gravatar.com/avatar/d2399743d3acbadec5b69550490b6c62?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png",
"id": 36064,
"gravatar_id": "d2399743d3acbadec5b69550490b6c62",
"login": "shock"
},
"url": "https://api.github.com/repos/pengwynn/octokit/issues/events/972713",
"id": 972713
},
{
"created_at": "2011-06-02T20:02:35Z",
"commit_id": null,
"event": "subscribed",
"actor": {
"url": "https://api.github.com/users/sferik",
"avatar_url": "https://secure.gravatar.com/avatar/1f74b13f1e5c6c69cb5d7fbaabb1e2cb?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png",
"id": 10308,
"gravatar_id": "1f74b13f1e5c6c69cb5d7fbaabb1e2cb",
"login": "sferik"
},
"url": "https://api.github.com/repos/pengwynn/octokit/issues/events/981039",
"id": 981039
},
{
"created_at": "2011-06-30T18:22:43Z",
"commit_id": null,
"event": "subscribed",
"actor": {
"url": "https://api.github.com/users/ctshryock",
"avatar_url": "https://secure.gravatar.com/avatar/dfb3948650131e4f0385c3328187cfca?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png",
"id": 61721,
"gravatar_id": "dfb3948650131e4f0385c3328187cfca",
"login": "ctshryock"
},
"url": "https://api.github.com/repos/pengwynn/octokit/issues/events/1503498",
"id": 1503498
}
]
134 changes: 134 additions & 0 deletions spec/fixtures/v3/repo_issues_events.json
@@ -0,0 +1,134 @@
[
{
"actor": {
"url": "https://api.github.com/users/ctshryock",
"gravatar_id": "dfb3948650131e4f0385c3328187cfca",
"login": "ctshryock",
"avatar_url": "https://secure.gravatar.com/avatar/dfb3948650131e4f0385c3328187cfca?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png",
"id": 61721
},
"url": "https://api.github.com/repos/pengwynn/octokit/issues/events/4942622",
"created_at": "2011-11-02T13:16:03Z",
"commit_id": null,
"event": "subscribed",
"issue": {
"body": "The brief description at the top has a link to http://wynnnetherland.com/projects/octokit , which now redirects back to github.com/pengwynn/octokit",
"url": "https://api.github.com/repos/pengwynn/octokit/issues/57",
"created_at": "2011-11-02T13:16:03Z",
"comments": 0,
"title": "Remove link in description",
"html_url": "https://github.com/pengwynn/octokit/issues/57",
"closed_at": null,
"assignee": null,
"labels": [

],
"number": 57,
"state": "open",
"user": {
"url": "https://api.github.com/users/ctshryock",
"gravatar_id": "dfb3948650131e4f0385c3328187cfca",
"login": "ctshryock",
"avatar_url": "https://secure.gravatar.com/avatar/dfb3948650131e4f0385c3328187cfca?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png",
"id": 61721
},
"pull_request": {
"patch_url": null,
"html_url": null,
"diff_url": null
},
"updated_at": "2011-11-02T13:16:03Z",
"id": 2121224,
"milestone": null
},
"id": 4942622
},
{
"actor": {
"url": "https://api.github.com/users/ctshryock",
"gravatar_id": "dfb3948650131e4f0385c3328187cfca",
"login": "ctshryock",
"avatar_url": "https://secure.gravatar.com/avatar/dfb3948650131e4f0385c3328187cfca?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png",
"id": 61721
},
"url": "https://api.github.com/repos/pengwynn/octokit/issues/events/4942562",
"created_at": "2011-11-02T13:13:26Z",
"commit_id": null,
"event": "closed",
"issue": {
"body": "Adding a test to cover the case where creating a repo for an organization, instead of a normal user. Added a new fixture, which has the `organization` section you get in return.\r\n\r\nTest coverage from 99.76% to 99.84%, hooray! ",
"url": "https://api.github.com/repos/pengwynn/octokit/issues/56",
"created_at": "2011-10-31T15:27:47Z",
"comments": 0,
"title": "Add spec test for creating a repo for an organization",
"html_url": "https://github.com/pengwynn/octokit/issues/56",
"closed_at": "2011-11-02T13:13:26Z",
"assignee": null,
"labels": [

],
"number": 56,
"state": "closed",
"user": {
"url": "https://api.github.com/users/ctshryock",
"gravatar_id": "dfb3948650131e4f0385c3328187cfca",
"login": "ctshryock",
"avatar_url": "https://secure.gravatar.com/avatar/dfb3948650131e4f0385c3328187cfca?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png",
"id": 61721
},
"pull_request": {
"patch_url": "https://github.com/pengwynn/octokit/pull/56.patch",
"html_url": "https://github.com/pengwynn/octokit/pull/56",
"diff_url": "https://github.com/pengwynn/octokit/pull/56.diff"
},
"updated_at": "2011-11-02T13:13:26Z",
"id": 2098069,
"milestone": null
},
"id": 4942562
},
{
"actor": {
"url": "https://api.github.com/users/ctshryock",
"gravatar_id": "dfb3948650131e4f0385c3328187cfca",
"login": "ctshryock",
"avatar_url": "https://secure.gravatar.com/avatar/dfb3948650131e4f0385c3328187cfca?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png",
"id": 61721
},
"url": "https://api.github.com/repos/pengwynn/octokit/issues/events/4942561",
"created_at": "2011-11-02T13:13:26Z",
"commit_id": "6aabedd72dcd4554f9243de7d23912bfa62c1c85",
"event": "merged",
"issue": {
"body": "Adding a test to cover the case where creating a repo for an organization, instead of a normal user. Added a new fixture, which has the `organization` section you get in return.\r\n\r\nTest coverage from 99.76% to 99.84%, hooray! ",
"url": "https://api.github.com/repos/pengwynn/octokit/issues/56",
"created_at": "2011-10-31T15:27:47Z",
"comments": 0,
"title": "Add spec test for creating a repo for an organization",
"html_url": "https://github.com/pengwynn/octokit/issues/56",
"closed_at": "2011-11-02T13:13:26Z",
"assignee": null,
"labels": [

],
"number": 56,
"state": "closed",
"user": {
"url": "https://api.github.com/users/ctshryock",
"gravatar_id": "dfb3948650131e4f0385c3328187cfca",
"login": "ctshryock",
"avatar_url": "https://secure.gravatar.com/avatar/dfb3948650131e4f0385c3328187cfca?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png",
"id": 61721
},
"pull_request": {
"patch_url": "https://github.com/pengwynn/octokit/pull/56.patch",
"html_url": "https://github.com/pengwynn/octokit/pull/56",
"diff_url": "https://github.com/pengwynn/octokit/pull/56.diff"
},
"updated_at": "2011-11-02T13:13:26Z",
"id": 2098069,
"milestone": null
},
"id": 4942561
}
]
30 changes: 30 additions & 0 deletions spec/octokit/client/issue_events_spec.rb
@@ -0,0 +1,30 @@
# -*- encoding: utf-8 -*-
require 'helper'

describe Octokit::Client::Issues do

before do
@client = Octokit::Client.new(:login => 'sferik')
end

describe ".issue_events" do

it "should list events for an issue" do
stub_get("/repos/pengwynn/octokit/issues/38/events").
to_return(:body => fixture("v3/issue_events.json"))
events = @client.issue_events("pengwynn/octokit", 38)
events.first.event.should == "mentioned"
events.last.actor.login.should == "ctshryock"
end

it "should get a single event" do
stub_get("/repos/pengwynn/octokit/issues/events/3094334").
to_return(:body => fixture("v3/issue_event.json"))
events = @client.issue_event("pengwynn/octokit", 3094334)
events.actor.login.should == "sferik"
events.event.should == "closed"
end

end

end
12 changes: 12 additions & 0 deletions spec/octokit/client/repositories_spec.rb
Expand Up @@ -351,4 +351,16 @@

end

describe ".events" do

it "should list event for all issues in a repository" do
stub_get("/repos/pengwynn/octokit/issues/events").
to_return(:body => fixture("v3/repo_issues_events.json"))
events = @client.repo_issue_events("pengwynn/octokit")
events.first.actor.login.should == "ctshryock"
events.first.event.should == "subscribed"
end

end

end

0 comments on commit 0f1d078

Please sign in to comment.