github_api 0.8.4 → 0.8.5
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +2 -1
- data/features/cassettes/issues/comments/create.yml +55 -0
- data/features/cassettes/issues/comments/delete.yml +46 -0
- data/features/cassettes/issues/comments/edit.yml +53 -0
- data/features/issues/comments.feature +35 -0
- data/features/issues/labels.feature +3 -3
- data/features/issues/milestones.feature +3 -3
- data/lib/github_api/authorizations.rb +5 -3
- data/lib/github_api/repos.rb +1 -1
- data/lib/github_api/version.rb +1 -1
- data/spec/github/issues/comments/create_spec.rb +50 -0
- data/spec/github/issues/comments/delete_spec.rb +36 -0
- data/spec/github/issues/comments/edit_spec.rb +50 -0
- data/spec/github/issues/comments/get_spec.rb +49 -0
- data/spec/github/issues/comments/list_spec.rb +79 -0
- data/spec/github/issues/comments_spec.rb +0 -294
- data/spec/github/issues/events/get_spec.rb +49 -0
- data/spec/github/issues/events/list_spec.rb +84 -0
- data/spec/github/issues/events_spec.rb +0 -155
- data/spec/github/issues/labels/remove_spec.rb +58 -0
- data/spec/github/issues/labels/replace_spec.rb +50 -0
- data/spec/github/issues/labels_spec.rb +1 -112
- metadata +44 -32
data/README.md
CHANGED
@@ -21,7 +21,8 @@ Supports all the API methods(nearly 200). It's build in a modular way, that is,
|
|
21
21
|
* Easy error handling.
|
22
22
|
* Custom mime types specification (Status: TODO)
|
23
23
|
* Flexible arguments parsing (Status: In progress).
|
24
|
-
*
|
24
|
+
* Request results caching (Status: TODO)
|
25
|
+
* Fully tested with test coverage above 90% with over 1,300 specs and 700 features.
|
25
26
|
|
26
27
|
## Installation
|
27
28
|
|
@@ -0,0 +1,55 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: https://<BASIC_AUTH>@api.github.com/repos/<USER>/github_api_test/issues/1/comments?access_token=<TOKEN>
|
6
|
+
body:
|
7
|
+
encoding: UTF-8
|
8
|
+
string: ! '{"body":"No worries this should be fixed now."}'
|
9
|
+
headers:
|
10
|
+
Accept:
|
11
|
+
- application/jsonapplication/vnd.github+json;q=0.7application/vnd.github.v3.raw+json;q=0.5application/vnd.github.beta.raw+json;q=0.1
|
12
|
+
Accept-Charset:
|
13
|
+
- utf-8
|
14
|
+
User-Agent:
|
15
|
+
- Github Ruby Gem 0.8.4
|
16
|
+
Content-Type:
|
17
|
+
- application/json
|
18
|
+
response:
|
19
|
+
status:
|
20
|
+
code: 201
|
21
|
+
message: Created
|
22
|
+
headers:
|
23
|
+
Server:
|
24
|
+
- nginx
|
25
|
+
Date:
|
26
|
+
- Tue, 25 Dec 2012 20:25:10 GMT
|
27
|
+
Content-Type:
|
28
|
+
- application/json; charset=utf-8
|
29
|
+
Connection:
|
30
|
+
- keep-alive
|
31
|
+
Status:
|
32
|
+
- 201 Created
|
33
|
+
Content-Length:
|
34
|
+
- '1210'
|
35
|
+
X-Content-Type-Options:
|
36
|
+
- nosniff
|
37
|
+
Location:
|
38
|
+
- https://api.github.com/repos/<USER>/github_api_test/issues/comments/11675857
|
39
|
+
X-Github-Media-Type:
|
40
|
+
- github.beta
|
41
|
+
Etag:
|
42
|
+
- ! '"13bdd542c6974f25226ac2c7f03207d8"'
|
43
|
+
X-Ratelimit-Limit:
|
44
|
+
- '5000'
|
45
|
+
Cache-Control:
|
46
|
+
- max-age=0, private, must-revalidate
|
47
|
+
X-Ratelimit-Remaining:
|
48
|
+
- '4999'
|
49
|
+
body:
|
50
|
+
encoding: US-ASCII
|
51
|
+
string: ! '{"issue_url":"https://api.github.com/repos/<USER>/github_api_test/issues/5020363","body":"No
|
52
|
+
worries this should be fixed now.","updated_at":"2012-12-25T20:25:10Z","url":"https://api.github.com/repos/<USER>/github_api_test/issues/comments/11675857","created_at":"2012-12-25T20:25:10Z","user":{"type":"User","starred_url":"https://api.github.com/users/<USER>/starred{/owner}{/repo}","gists_url":"https://api.github.com/users/<USER>/gists{/gist_id}","repos_url":"https://api.github.com/users/<USER>/repos","followers_url":"https://api.github.com/users/<USER>/followers","following_url":"https://api.github.com/users/<USER>/following","received_events_url":"https://api.github.com/users/<USER>/received_events","organizations_url":"https://api.github.com/users/<USER>/orgs","url":"https://api.github.com/users/<USER>","gravatar_id":"80cbc0fc6c03d43f495b2342b31fe4fa","avatar_url":"https://secure.gravatar.com/avatar/80cbc0fc6c03d43f495b2342b31fe4fa?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-user-420.png","login":"<USER>","subscriptions_url":"https://api.github.com/users/<USER>/subscriptions","id":1223156,"events_url":"https://api.github.com/users/<USER>/events{/privacy}"},"id":11675857}'
|
53
|
+
http_version: !!null
|
54
|
+
recorded_at: Tue, 25 Dec 2012 20:25:10 GMT
|
55
|
+
recorded_with: VCR 2.3.0
|
@@ -0,0 +1,46 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: delete
|
5
|
+
uri: https://<BASIC_AUTH>@api.github.com/repos/<USER>/github_api_test/issues/comments/11675857?access_token=<TOKEN>
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
Accept:
|
11
|
+
- application/jsonapplication/vnd.github+json;q=0.7application/vnd.github.v3.raw+json;q=0.5application/vnd.github.beta.raw+json;q=0.1
|
12
|
+
Accept-Charset:
|
13
|
+
- utf-8
|
14
|
+
User-Agent:
|
15
|
+
- Github Ruby Gem 0.8.4
|
16
|
+
Content-Type:
|
17
|
+
- application/json
|
18
|
+
response:
|
19
|
+
status:
|
20
|
+
code: 204
|
21
|
+
message: No Content
|
22
|
+
headers:
|
23
|
+
Server:
|
24
|
+
- nginx
|
25
|
+
Date:
|
26
|
+
- Tue, 25 Dec 2012 20:33:40 GMT
|
27
|
+
Connection:
|
28
|
+
- keep-alive
|
29
|
+
Status:
|
30
|
+
- 204 No Content
|
31
|
+
X-Ratelimit-Limit:
|
32
|
+
- '5000'
|
33
|
+
X-Content-Type-Options:
|
34
|
+
- nosniff
|
35
|
+
Cache-Control:
|
36
|
+
- ''
|
37
|
+
X-Github-Media-Type:
|
38
|
+
- github.beta
|
39
|
+
X-Ratelimit-Remaining:
|
40
|
+
- '4996'
|
41
|
+
body:
|
42
|
+
encoding: US-ASCII
|
43
|
+
string: ''
|
44
|
+
http_version: !!null
|
45
|
+
recorded_at: Tue, 25 Dec 2012 20:33:40 GMT
|
46
|
+
recorded_with: VCR 2.3.0
|
@@ -0,0 +1,53 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: patch
|
5
|
+
uri: https://<BASIC_AUTH>@api.github.com/repos/<USER>/github_api_test/issues/comments/11675857?access_token=<TOKEN>
|
6
|
+
body:
|
7
|
+
encoding: UTF-8
|
8
|
+
string: ! '{"body":"No worries this should be fixed now."}'
|
9
|
+
headers:
|
10
|
+
Accept:
|
11
|
+
- application/jsonapplication/vnd.github+json;q=0.7application/vnd.github.v3.raw+json;q=0.5application/vnd.github.beta.raw+json;q=0.1
|
12
|
+
Accept-Charset:
|
13
|
+
- utf-8
|
14
|
+
User-Agent:
|
15
|
+
- Github Ruby Gem 0.8.4
|
16
|
+
Content-Type:
|
17
|
+
- application/json
|
18
|
+
response:
|
19
|
+
status:
|
20
|
+
code: 200
|
21
|
+
message: OK
|
22
|
+
headers:
|
23
|
+
Server:
|
24
|
+
- nginx
|
25
|
+
Date:
|
26
|
+
- Tue, 25 Dec 2012 20:29:42 GMT
|
27
|
+
Content-Type:
|
28
|
+
- application/json; charset=utf-8
|
29
|
+
Connection:
|
30
|
+
- keep-alive
|
31
|
+
Status:
|
32
|
+
- 200 OK
|
33
|
+
X-Github-Media-Type:
|
34
|
+
- github.beta
|
35
|
+
Etag:
|
36
|
+
- ! '"2f5b3d8fd30ad241cdf8be89ea191a54"'
|
37
|
+
Cache-Control:
|
38
|
+
- max-age=0, private, must-revalidate
|
39
|
+
Content-Length:
|
40
|
+
- '1210'
|
41
|
+
X-Content-Type-Options:
|
42
|
+
- nosniff
|
43
|
+
X-Ratelimit-Remaining:
|
44
|
+
- '4997'
|
45
|
+
X-Ratelimit-Limit:
|
46
|
+
- '5000'
|
47
|
+
body:
|
48
|
+
encoding: US-ASCII
|
49
|
+
string: ! '{"issue_url":"https://api.github.com/repos/<USER>/github_api_test/issues/5020363","body":"No
|
50
|
+
worries this should be fixed now.","updated_at":"2012-12-25T20:25:10Z","url":"https://api.github.com/repos/<USER>/github_api_test/issues/comments/11675857","created_at":"2012-12-25T20:25:10Z","user":{"type":"User","received_events_url":"https://api.github.com/users/<USER>/received_events","avatar_url":"https://secure.gravatar.com/avatar/80cbc0fc6c03d43f495b2342b31fe4fa?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-user-420.png","gists_url":"https://api.github.com/users/<USER>/gists{/gist_id}","followers_url":"https://api.github.com/users/<USER>/followers","following_url":"https://api.github.com/users/<USER>/following","organizations_url":"https://api.github.com/users/<USER>/orgs","starred_url":"https://api.github.com/users/<USER>/starred{/owner}{/repo}","url":"https://api.github.com/users/<USER>","gravatar_id":"80cbc0fc6c03d43f495b2342b31fe4fa","repos_url":"https://api.github.com/users/<USER>/repos","login":"<USER>","events_url":"https://api.github.com/users/<USER>/events{/privacy}","subscriptions_url":"https://api.github.com/users/<USER>/subscriptions","id":1223156},"id":11675857}'
|
51
|
+
http_version: !!null
|
52
|
+
recorded_at: Tue, 25 Dec 2012 20:29:42 GMT
|
53
|
+
recorded_with: VCR 2.3.0
|
@@ -35,3 +35,38 @@ Feature: Issues Comments API
|
|
35
35
|
Then the response status should be 200
|
36
36
|
And the response type should be JSON
|
37
37
|
And the response should not be empty
|
38
|
+
|
39
|
+
Scenario: Create
|
40
|
+
|
41
|
+
Given I want to create resource with the following params:
|
42
|
+
| user | repo | issue_id |
|
43
|
+
| murek | github_api_test | 1 |
|
44
|
+
And I pass the following request options:
|
45
|
+
| body |
|
46
|
+
| No worries this should be fixed now. |
|
47
|
+
When I make request within a cassette named "issues/comments/create" and match on method
|
48
|
+
Then the response status should be 201
|
49
|
+
And the response type should be JSON
|
50
|
+
And the response should not be empty
|
51
|
+
|
52
|
+
Scenario: Edit
|
53
|
+
|
54
|
+
Given I want to edit resource with the following params:
|
55
|
+
| user | repo | comment_id |
|
56
|
+
| murek | github_api_test | 11675857 |
|
57
|
+
And I pass the following request options:
|
58
|
+
| body |
|
59
|
+
| No worries this should be fixed now. |
|
60
|
+
When I make request within a cassette named "issues/comments/edit" and match on method
|
61
|
+
Then the response status should be 200
|
62
|
+
And the response type should be JSON
|
63
|
+
And the response should not be empty
|
64
|
+
|
65
|
+
Scenario: Delete
|
66
|
+
|
67
|
+
Given I want to delete resource with the following params:
|
68
|
+
| user | repo | comment_id |
|
69
|
+
| murek | github_api_test | 11675857 |
|
70
|
+
When I make request within a cassette named "issues/comments/delete" and match on method
|
71
|
+
Then the response status should be 204
|
72
|
+
|
@@ -57,7 +57,7 @@ Feature: Labels API
|
|
57
57
|
And I pass the following request options:
|
58
58
|
| name | color |
|
59
59
|
| api | FFFFFF |
|
60
|
-
When I make request within a cassette named "issues/labels/create" and match on method
|
60
|
+
When I make request within a cassette named "issues/labels/create" and match on method
|
61
61
|
Then the response status should be 201
|
62
62
|
And the response type should be JSON
|
63
63
|
And the response should not be empty
|
@@ -70,7 +70,7 @@ Feature: Labels API
|
|
70
70
|
And I pass the following request options:
|
71
71
|
| name | color |
|
72
72
|
| api | 000000 |
|
73
|
-
When I make request within a cassette named "issues/labels/update" and match on method
|
73
|
+
When I make request within a cassette named "issues/labels/update" and match on method
|
74
74
|
Then the response status should be 200
|
75
75
|
And the response type should be JSON
|
76
76
|
And the response should not be empty
|
@@ -80,6 +80,6 @@ Feature: Labels API
|
|
80
80
|
Given I want to delete resource with the following params:
|
81
81
|
| user | repo | label_name |
|
82
82
|
| murek | github_api_test | api |
|
83
|
-
When I make request within a cassette named "issues/labels/delete" and match on method
|
83
|
+
When I make request within a cassette named "issues/labels/delete" and match on method
|
84
84
|
Then the response status should be 204
|
85
85
|
|
@@ -34,7 +34,7 @@ Feature: Milestones API
|
|
34
34
|
And I pass the following request options:
|
35
35
|
| title | state | description |
|
36
36
|
| fix-all | open | fixing all issues |
|
37
|
-
When I make request within a cassette named "issues/milestones/create" and match on method
|
37
|
+
When I make request within a cassette named "issues/milestones/create" and match on method
|
38
38
|
Then the response status should be 201
|
39
39
|
And the response type should be JSON
|
40
40
|
And the response should not be empty
|
@@ -47,7 +47,7 @@ Feature: Milestones API
|
|
47
47
|
And I pass the following request options:
|
48
48
|
| state |
|
49
49
|
| closed |
|
50
|
-
When I make request within a cassette named "issues/milestones/update" and match on method
|
50
|
+
When I make request within a cassette named "issues/milestones/update" and match on method
|
51
51
|
Then the response status should be 200
|
52
52
|
And the response type should be JSON
|
53
53
|
And the response should not be empty
|
@@ -57,6 +57,6 @@ Feature: Milestones API
|
|
57
57
|
Given I want to delete resource with the following params:
|
58
58
|
| user | repo | milestone_id |
|
59
59
|
| murek | github_api_test | 1 |
|
60
|
-
When I make request within a cassette named "issues/milestones/delete" and match on method
|
60
|
+
When I make request within a cassette named "issues/milestones/delete" and match on method
|
61
61
|
Then the response status should be 204
|
62
62
|
|
@@ -7,6 +7,10 @@ module Github
|
|
7
7
|
scopes
|
8
8
|
add_scopes
|
9
9
|
remove_scopes
|
10
|
+
note
|
11
|
+
note_url
|
12
|
+
client_id
|
13
|
+
client_secret
|
10
14
|
].freeze
|
11
15
|
|
12
16
|
# Creates new OAuth Authorizations API
|
@@ -82,12 +86,12 @@ module Github
|
|
82
86
|
def update(authorization_id, params={})
|
83
87
|
_check_if_authenticated
|
84
88
|
assert_presence_of authorization_id
|
85
|
-
|
86
89
|
normalize! params
|
87
90
|
filter! VALID_AUTH_PARAM_NAMES, params
|
88
91
|
|
89
92
|
patch_request("/authorizations/#{authorization_id}", params)
|
90
93
|
end
|
94
|
+
alias :edit :update
|
91
95
|
|
92
96
|
# Delete an authorization
|
93
97
|
#
|
@@ -97,9 +101,7 @@ module Github
|
|
97
101
|
def delete(authorization_id, params={})
|
98
102
|
_check_if_authenticated
|
99
103
|
assert_presence_of authorization_id
|
100
|
-
|
101
104
|
normalize! params
|
102
|
-
filter! VALID_AUTH_PARAM_NAMES, params
|
103
105
|
|
104
106
|
delete_request("/authorizations/#{authorization_id}", params)
|
105
107
|
end
|
data/lib/github_api/repos.rb
CHANGED
@@ -134,7 +134,7 @@ module Github
|
|
134
134
|
assert_presence_of user_name, repo_name, branch
|
135
135
|
normalize! params
|
136
136
|
|
137
|
-
get_request("repos/#{user_name}/#{repo_name}/branches/#{branch}", params)
|
137
|
+
get_request("/repos/#{user_name}/#{repo_name}/branches/#{branch}", params)
|
138
138
|
end
|
139
139
|
|
140
140
|
# Create a new repository for the autheticated user.
|
data/lib/github_api/version.rb
CHANGED
@@ -0,0 +1,50 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Github::Issues::Comments, '#create' do
|
6
|
+
let(:user) { 'peter-murach' }
|
7
|
+
let(:repo) { 'github' }
|
8
|
+
let(:issue_id) { 1 }
|
9
|
+
let(:inputs) { { 'body' => 'a new comment' } }
|
10
|
+
let(:request_path) { "/repos/#{user}/#{repo}/issues/#{issue_id}/comments" }
|
11
|
+
|
12
|
+
before {
|
13
|
+
stub_post(request_path).with(:body => inputs).
|
14
|
+
to_return(:body => body, :status => status,
|
15
|
+
:headers => {:content_type => "application/json; charset=utf-8"})
|
16
|
+
}
|
17
|
+
|
18
|
+
after { reset_authentication_for(subject) }
|
19
|
+
|
20
|
+
context "resouce created" do
|
21
|
+
let(:body) { fixture('issues/comment.json') }
|
22
|
+
let(:status) { 201 }
|
23
|
+
|
24
|
+
it "should fail to create resource if 'body' input is missing" do
|
25
|
+
expect {
|
26
|
+
subject.create user, repo, issue_id, inputs.except('body')
|
27
|
+
}.to raise_error(Github::Error::RequiredParams)
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should create resource successfully" do
|
31
|
+
subject.create user, repo, issue_id, inputs
|
32
|
+
a_post(request_path).with(inputs).should have_been_made
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should return the resource" do
|
36
|
+
comment = subject.create user, repo, issue_id, inputs
|
37
|
+
comment.should be_a Hashie::Mash
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should get the comment information" do
|
41
|
+
comment = subject.create user, repo, issue_id, inputs
|
42
|
+
comment.user.login.should == 'octocat'
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
it_should_behave_like 'request failure' do
|
47
|
+
let(:requestable) { subject.create user, repo, issue_id, inputs }
|
48
|
+
end
|
49
|
+
|
50
|
+
end # create
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Github::Issues::Comments, '#delete' do
|
6
|
+
let(:user) { 'peter-murach' }
|
7
|
+
let(:repo) { 'github' }
|
8
|
+
let(:comment_id) { '1' }
|
9
|
+
let(:request_path) { "/repos/#{user}/#{repo}/issues/comments/#{comment_id}" }
|
10
|
+
|
11
|
+
before {
|
12
|
+
stub_delete(request_path).to_return(:body => body, :status => status,
|
13
|
+
:headers => {:content_type => "application/json; charset=utf-8"})
|
14
|
+
}
|
15
|
+
|
16
|
+
after { reset_authentication_for(subject) }
|
17
|
+
|
18
|
+
context "resouce deleted" do
|
19
|
+
let(:body) { fixture('issues/comment.json') }
|
20
|
+
let(:status) { 204 }
|
21
|
+
|
22
|
+
it "should fail to delete resource if comment_id is missing" do
|
23
|
+
expect { subject.delete user, repo, nil }.to raise_error(ArgumentError)
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should create resource successfully" do
|
27
|
+
subject.delete user, repo, comment_id
|
28
|
+
a_delete(request_path).should have_been_made
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
it_should_behave_like 'request failure' do
|
33
|
+
let(:requestable) { subject.delete user, repo, comment_id }
|
34
|
+
end
|
35
|
+
|
36
|
+
end # delete
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Github::Issues::Comments, '#edit' do
|
6
|
+
let(:user) { 'peter-murach' }
|
7
|
+
let(:repo) { 'github' }
|
8
|
+
let(:comment_id) { 1 }
|
9
|
+
let(:inputs) { { 'body' => 'a new comment' } }
|
10
|
+
let(:request_path) { "/repos/#{user}/#{repo}/issues/comments/#{comment_id}" }
|
11
|
+
|
12
|
+
before {
|
13
|
+
stub_patch(request_path).with(:body => inputs).
|
14
|
+
to_return(:body => body, :status => status,
|
15
|
+
:headers => {:content_type => "application/json; charset=utf-8"})
|
16
|
+
}
|
17
|
+
|
18
|
+
after { reset_authentication_for(subject) }
|
19
|
+
|
20
|
+
context "resouce edited" do
|
21
|
+
let(:body) { fixture('issues/comment.json') }
|
22
|
+
let(:status) { 201 }
|
23
|
+
|
24
|
+
it "should fail to create resource if 'body' input is missing" do
|
25
|
+
expect {
|
26
|
+
subject.edit user, repo, comment_id, inputs.except('body')
|
27
|
+
}.to raise_error(Github::Error::RequiredParams)
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should create resource successfully" do
|
31
|
+
subject.edit user, repo, comment_id, inputs
|
32
|
+
a_patch(request_path).with(inputs).should have_been_made
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should return the resource" do
|
36
|
+
comment = subject.edit user, repo, comment_id, inputs
|
37
|
+
comment.should be_a Hashie::Mash
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should get the comment information" do
|
41
|
+
comment = subject.edit user, repo, comment_id, inputs
|
42
|
+
comment.user.login.should == 'octocat'
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
it_should_behave_like 'request failure' do
|
47
|
+
let(:requestable) { subject.edit user, repo, comment_id, inputs }
|
48
|
+
end
|
49
|
+
|
50
|
+
end # edit
|