octokit 1.18.0 → 1.19.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +1 -1
- data/.rspec +1 -0
- data/CHANGELOG.md +25 -0
- data/{LICENSE → LICENSE.md} +0 -0
- data/README.md +25 -8
- data/lib/faraday/response/raise_octokit_error.rb +4 -1
- data/lib/octokit/client.rb +6 -0
- data/lib/octokit/client/authorizations.rb +20 -7
- data/lib/octokit/client/commits.rb +120 -13
- data/lib/octokit/client/contents.rb +3 -4
- data/lib/octokit/client/downloads.rb +4 -3
- data/lib/octokit/client/emojis.rb +1 -1
- data/lib/octokit/client/events.rb +4 -4
- data/lib/octokit/client/gists.rb +33 -31
- data/lib/octokit/client/issues.rb +15 -15
- data/lib/octokit/client/labels.rb +13 -13
- data/lib/octokit/client/markdown.rb +2 -1
- data/lib/octokit/client/milestones.rb +6 -6
- data/lib/octokit/client/notifications.rb +222 -0
- data/lib/octokit/client/objects.rb +4 -4
- data/lib/octokit/client/organizations.rb +65 -20
- data/lib/octokit/client/pub_sub_hubbub.rb +2 -2
- data/lib/octokit/client/pulls.rb +91 -3
- data/lib/octokit/client/rate_limit.rb +20 -0
- data/lib/octokit/client/refs.rb +4 -4
- data/lib/octokit/client/repositories.rb +106 -37
- data/lib/octokit/client/say.rb +14 -0
- data/lib/octokit/client/statuses.rb +2 -2
- data/lib/octokit/client/users.rb +92 -24
- data/lib/octokit/connection.rb +21 -21
- data/lib/octokit/request.rb +47 -36
- data/lib/octokit/version.rb +1 -1
- data/octokit.gemspec +25 -25
- data/spec/fixtures/{v3/authorization.json → authorization.json} +0 -0
- data/spec/fixtures/{v3/authorizations.json → authorizations.json} +0 -0
- data/spec/fixtures/{v3/blob.json → blob.json} +0 -0
- data/spec/fixtures/{v3/blob_create.json → blob_create.json} +0 -0
- data/spec/fixtures/{v3/branches.json → branches.json} +0 -0
- data/spec/fixtures/{v3/collaborators.json → collaborators.json} +0 -0
- data/spec/fixtures/{v3/comment.json → comment.json} +0 -0
- data/spec/fixtures/{v3/comments.json → comments.json} +0 -0
- data/spec/fixtures/{v3/commit.json → commit.json} +0 -0
- data/spec/fixtures/{v3/commit_comment.json → commit_comment.json} +0 -0
- data/spec/fixtures/{v3/commit_comment_create.json → commit_comment_create.json} +0 -0
- data/spec/fixtures/{v3/commit_comment_update.json → commit_comment_update.json} +0 -0
- data/spec/fixtures/{v3/commit_comments.json → commit_comments.json} +0 -0
- data/spec/fixtures/{v3/commit_create.json → commit_create.json} +0 -0
- data/spec/fixtures/{v3/commits.json → commits.json} +0 -0
- data/spec/fixtures/{v3/compare.json → compare.json} +0 -0
- data/spec/fixtures/{v3/contents.json → contents.json} +0 -0
- data/spec/fixtures/{v3/contributors.json → contributors.json} +0 -0
- data/spec/fixtures/{v3/download.json → download.json} +0 -0
- data/spec/fixtures/{v3/download_create.json → download_create.json} +0 -0
- data/spec/fixtures/{v3/downloads.json → downloads.json} +0 -0
- data/spec/fixtures/{v3/emails.json → emails.json} +0 -0
- data/spec/fixtures/{v3/emojis.json → emojis.json} +0 -0
- data/spec/fixtures/{v3/followers.json → followers.json} +0 -0
- data/spec/fixtures/{v3/following.json → following.json} +0 -0
- data/spec/fixtures/{v3/forks.json → forks.json} +0 -0
- data/spec/fixtures/{v3/gist.json → gist.json} +0 -0
- data/spec/fixtures/{v3/gist_comment.json → gist_comment.json} +0 -0
- data/spec/fixtures/{v3/gist_comment_create.json → gist_comment_create.json} +0 -0
- data/spec/fixtures/{v3/gist_comment_update.json → gist_comment_update.json} +0 -0
- data/spec/fixtures/{v3/gist_comments.json → gist_comments.json} +0 -0
- data/spec/fixtures/{v3/gists.json → gists.json} +0 -0
- data/spec/fixtures/{v3/hook.json → hook.json} +0 -0
- data/spec/fixtures/{v3/hooks.json → hooks.json} +0 -0
- data/spec/fixtures/{v3/issue.json → issue.json} +0 -0
- data/spec/fixtures/{v3/issue_closed.json → issue_closed.json} +0 -0
- data/spec/fixtures/{v3/issue_event.json → issue_event.json} +0 -0
- data/spec/fixtures/{v3/issue_events.json → issue_events.json} +0 -0
- data/spec/fixtures/issue_full.json +38 -0
- data/spec/fixtures/{v3/issues.json → issues.json} +0 -0
- data/spec/fixtures/{v3/label.json → label.json} +0 -0
- data/spec/fixtures/{v3/labels.json → labels.json} +0 -0
- data/spec/fixtures/{v3/languages.json → languages.json} +0 -0
- data/spec/fixtures/{v3/list_commit_comments.json → list_commit_comments.json} +0 -0
- data/spec/fixtures/{v3/markdown_gfm → markdown_gfm} +0 -0
- data/spec/fixtures/{v3/merge.json → merge.json} +0 -0
- data/spec/fixtures/{v3/milestone.json → milestone.json} +0 -0
- data/spec/fixtures/{v3/milestones.json → milestones.json} +0 -0
- data/spec/fixtures/{v3/not_found.json → not_found.json} +0 -0
- data/spec/fixtures/notification_thread.json +32 -0
- data/spec/fixtures/notifications.json +32 -0
- data/spec/fixtures/{v3/organization-repositories.json → organization-repositories.json} +0 -0
- data/spec/fixtures/{v3/organization-repository.json → organization-repository.json} +0 -0
- data/spec/fixtures/{v3/organization.json → organization.json} +0 -0
- data/spec/fixtures/{v3/organization_members.json → organization_members.json} +0 -0
- data/spec/fixtures/{v3/organization_team_members.json → organization_team_members.json} +0 -0
- data/spec/fixtures/{v3/organization_team_repos.json → organization_team_repos.json} +0 -0
- data/spec/fixtures/{v3/organizations.json → organizations.json} +0 -0
- data/spec/fixtures/{v3/public_events.json → public_events.json} +0 -0
- data/spec/fixtures/{v3/public_gists.json → public_gists.json} +0 -0
- data/spec/fixtures/{v3/public_key.json → public_key.json} +0 -0
- data/spec/fixtures/public_key_update.json +5 -0
- data/spec/fixtures/{v3/public_keys.json → public_keys.json} +0 -0
- data/spec/fixtures/{v3/pull_created.json → pull_created.json} +0 -0
- data/spec/fixtures/{v3/pull_request.json → pull_request.json} +0 -0
- data/spec/fixtures/pull_request_comment.json +35 -0
- data/spec/fixtures/pull_request_comment_create.json +35 -0
- data/spec/fixtures/pull_request_comment_reply.json +35 -0
- data/spec/fixtures/pull_request_comment_update.json +35 -0
- data/spec/fixtures/{v3/pull_request_comments.json → pull_request_comments.json} +0 -0
- data/spec/fixtures/{v3/pull_request_commits.json → pull_request_commits.json} +0 -0
- data/spec/fixtures/{v3/pull_request_files.json → pull_request_files.json} +0 -0
- data/spec/fixtures/{v3/pull_request_merged.json → pull_request_merged.json} +0 -0
- data/spec/fixtures/{v3/pull_requests.json → pull_requests.json} +0 -0
- data/spec/fixtures/{v3/pull_update.json → pull_update.json} +0 -0
- data/spec/fixtures/{v3/readme.json → readme.json} +0 -0
- data/spec/fixtures/{v3/ref.json → ref.json} +0 -0
- data/spec/fixtures/{v3/ref_create.json → ref_create.json} +0 -0
- data/spec/fixtures/{v3/ref_update.json → ref_update.json} +0 -0
- data/spec/fixtures/{v3/refs.json → refs.json} +0 -0
- data/spec/fixtures/{v3/refs_tags.json → refs_tags.json} +0 -0
- data/spec/fixtures/{v3/repo_assignees.json → repo_assignees.json} +0 -0
- data/spec/fixtures/{v3/repo_events.json → repo_events.json} +0 -0
- data/spec/fixtures/{v3/repo_issues_events.json → repo_issues_events.json} +0 -0
- data/spec/fixtures/{v3/repositories.json → repositories.json} +0 -0
- data/spec/fixtures/{v3/repository.json → repository.json} +0 -0
- data/spec/fixtures/repository_notifications.json +32 -0
- data/spec/fixtures/say.txt +22 -0
- data/spec/fixtures/say_custom.txt +22 -0
- data/spec/fixtures/{v3/stargazers.json → stargazers.json} +0 -0
- data/spec/fixtures/{v3/starred.json → starred.json} +0 -0
- data/spec/fixtures/{v3/starred_gists.json → starred_gists.json} +0 -0
- data/spec/fixtures/{v3/status.json → status.json} +0 -0
- data/spec/fixtures/{v3/statuses.json → statuses.json} +0 -0
- data/spec/fixtures/subscribers.json +9 -0
- data/spec/fixtures/subscription.json +8 -0
- data/spec/fixtures/subscription_update.json +8 -0
- data/spec/fixtures/subscriptions.json +39 -0
- data/spec/fixtures/{v3/tag.json → tag.json} +0 -0
- data/spec/fixtures/{v3/tag_create.json → tag_create.json} +0 -0
- data/spec/fixtures/{v3/tags.json → tags.json} +0 -0
- data/spec/fixtures/{v3/team.json → team.json} +0 -0
- data/spec/fixtures/{v3/teams.json → teams.json} +0 -0
- data/spec/fixtures/thread_subscription.json +8 -0
- data/spec/fixtures/thread_subscription_update.json +8 -0
- data/spec/fixtures/{v3/tree.json → tree.json} +0 -0
- data/spec/fixtures/{v3/tree_create.json → tree_create.json} +0 -0
- data/spec/fixtures/{v3/user.json → user.json} +0 -0
- data/spec/fixtures/{v3/user_events.json → user_events.json} +0 -0
- data/spec/fixtures/validation_failed.json +11 -0
- data/spec/fixtures/{v3/watched.json → watched.json} +0 -0
- data/spec/fixtures/{v3/watchers.json → watchers.json} +0 -0
- data/spec/helper.rb +13 -2
- data/spec/octokit/client/authorizations_spec.rb +44 -7
- data/spec/octokit/client/commits_spec.rb +136 -11
- data/spec/octokit/client/contents_spec.rb +6 -3
- data/spec/octokit/client/downloads_spec.rb +5 -6
- data/spec/octokit/client/emojis_spec.rb +1 -1
- data/spec/octokit/client/events_spec.rb +5 -5
- data/spec/octokit/client/gists_spec.rb +20 -20
- data/spec/octokit/client/issue_events_spec.rb +2 -2
- data/spec/octokit/client/issues_spec.rb +25 -14
- data/spec/octokit/client/labels_spec.rb +18 -22
- data/spec/octokit/client/markdown_spec.rb +1 -1
- data/spec/octokit/client/milestones_spec.rb +8 -8
- data/spec/octokit/client/notifications_spec.rb +141 -0
- data/spec/octokit/client/objects_spec.rb +6 -6
- data/spec/octokit/client/organizations_spec.rb +65 -13
- data/spec/octokit/client/pub_sub_hubbub/service_hooks_spec.rb +4 -4
- data/spec/octokit/client/pub_sub_hubbub_spec.rb +3 -3
- data/spec/octokit/client/pulls_spec.rb +81 -10
- data/spec/octokit/client/refs_spec.rb +7 -7
- data/spec/octokit/client/repositories_spec.rb +86 -34
- data/spec/octokit/client/say_spec.rb +37 -0
- data/spec/octokit/client/statuses_spec.rb +2 -2
- data/spec/octokit/client/users_spec.rb +65 -16
- data/spec/octokit/client_spec.rb +37 -11
- data/spec/{repository_spec.rb → octokit/repository_spec.rb} +0 -0
- data/spec/octokit_spec.rb +1 -1
- metadata +240 -196
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,32 @@
|
|
1
|
+
[
|
2
|
+
{
|
3
|
+
"id": 1,
|
4
|
+
"repository": {
|
5
|
+
"id": 1296269,
|
6
|
+
"owner": {
|
7
|
+
"login": "octocat",
|
8
|
+
"id": 1,
|
9
|
+
"avatar_url": "https://github.com/images/error/octocat_happy.gif",
|
10
|
+
"gravatar_id": "somehexcode",
|
11
|
+
"url": "https://api.github.com/users/octocat"
|
12
|
+
},
|
13
|
+
"name": "Hello-World",
|
14
|
+
"full_name": "octocat/Hello-World",
|
15
|
+
"description": "This your first repo!",
|
16
|
+
"private": false,
|
17
|
+
"fork": false,
|
18
|
+
"url": "https://api.github.com/repos/octocat/Hello-World",
|
19
|
+
"html_url": "https://github.com/octocat/Hello-World"
|
20
|
+
},
|
21
|
+
"subject": {
|
22
|
+
"title": "Greetings",
|
23
|
+
"url": "https://api.github.com/repos/pengwynn/octokit/issues/123",
|
24
|
+
"latest_comment_url": "https://api.github.com/repos/pengwynn/octokit/issues/comments/123"
|
25
|
+
},
|
26
|
+
"reason": "subscribed",
|
27
|
+
"unread": true,
|
28
|
+
"updated_at": "2012-09-25T07:54:41-07:00",
|
29
|
+
"last_read_at": "2012-09-25T07:54:41-07:00",
|
30
|
+
"url": "https://api.github.com/notifications/threads/1"
|
31
|
+
}
|
32
|
+
]
|
@@ -0,0 +1,22 @@
|
|
1
|
+
|
2
|
+
MMM. .MMM
|
3
|
+
MMMMMMMMMMMMMMMMMMM
|
4
|
+
MMMMMMMMMMMMMMMMMMM _____________________________________________
|
5
|
+
MMMMMMMMMMMMMMMMMMMMM | |
|
6
|
+
MMMMMMMMMMMMMMMMMMMMMMM | Half measures are as bad as nothing at all. |
|
7
|
+
MMMMMMMMMMMMMMMMMMMMMMMM |_ _________________________________________|
|
8
|
+
MMMM::- -:::::::- -::MMMM |/
|
9
|
+
MM~:~ ~:::::~ ~:~MM
|
10
|
+
.. MMMMM::. .:::+:::. .::MMMMM ..
|
11
|
+
.MM::::: ._. :::::MM.
|
12
|
+
MMMM;:::::;MMMM
|
13
|
+
-MM MMMMMMM
|
14
|
+
^ M+ MMMMMMMMM
|
15
|
+
MMMMMMM MM MM MM
|
16
|
+
MM MM MM MM
|
17
|
+
MM MM MM MM
|
18
|
+
.~~MM~MM~MM~MM~~.
|
19
|
+
~~~~MM:~MM~~~MM~:MM~~~~
|
20
|
+
~~~~~~==~==~~~==~==~~~~~~
|
21
|
+
~~~~~~==~==~==~==~~~~~~
|
22
|
+
:~==~==~==~==~~
|
@@ -0,0 +1,22 @@
|
|
1
|
+
|
2
|
+
MMM. .MMM
|
3
|
+
MMMMMMMMMMMMMMMMMMM
|
4
|
+
MMMMMMMMMMMMMMMMMMM ______________________________
|
5
|
+
MMMMMMMMMMMMMMMMMMMMM | |
|
6
|
+
MMMMMMMMMMMMMMMMMMMMMMM | There is no need to be upset |
|
7
|
+
MMMMMMMMMMMMMMMMMMMMMMMM |_ __________________________|
|
8
|
+
MMMM::- -:::::::- -::MMMM |/
|
9
|
+
MM~:~ ~:::::~ ~:~MM
|
10
|
+
.. MMMMM::. .:::+:::. .::MMMMM ..
|
11
|
+
.MM::::: ._. :::::MM.
|
12
|
+
MMMM;:::::;MMMM
|
13
|
+
-MM MMMMMMM
|
14
|
+
^ M+ MMMMMMMMM
|
15
|
+
MMMMMMM MM MM MM
|
16
|
+
MM MM MM MM
|
17
|
+
MM MM MM MM
|
18
|
+
.~~MM~MM~MM~MM~~.
|
19
|
+
~~~~MM:~MM~~~MM~:MM~~~~
|
20
|
+
~~~~~~==~==~~~==~==~~~~~~
|
21
|
+
~~~~~~==~==~==~==~~~~~~
|
22
|
+
:~==~==~==~==~~
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,9 @@
|
|
1
|
+
[
|
2
|
+
{
|
3
|
+
"url": "https://api.github.com/users/pengwynn",
|
4
|
+
"login": "pengwynn",
|
5
|
+
"avatar_url": "https://secure.gravatar.com/avatar/7e19cd5486b5d6dc1ef90e671ba52ae0?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-user-420.png",
|
6
|
+
"gravatar_id": "7e19cd5486b5d6dc1ef90e671ba52ae0",
|
7
|
+
"id": 865
|
8
|
+
}
|
9
|
+
]
|
@@ -0,0 +1,39 @@
|
|
1
|
+
[
|
2
|
+
{
|
3
|
+
"watchers": 12,
|
4
|
+
"url": "https://api.github.com/repos/pengwynn/ujs_sort_helper",
|
5
|
+
"svn_url": "https://github.com/pengwynn/ujs_sort_helper",
|
6
|
+
"watchers_count": 12,
|
7
|
+
"owner": {
|
8
|
+
"url": "https://api.github.com/users/pengwynn",
|
9
|
+
"avatar_url": "https://secure.gravatar.com/avatar/7e19cd5486b5d6dc1ef90e671ba52ae0?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-user-420.png",
|
10
|
+
"gravatar_id": "7e19cd5486b5d6dc1ef90e671ba52ae0",
|
11
|
+
"login": "pengwynn",
|
12
|
+
"id": 865
|
13
|
+
},
|
14
|
+
"language": "JavaScript",
|
15
|
+
"has_wiki": true,
|
16
|
+
"description": "Unobtrusive sort helper for Rails",
|
17
|
+
"clone_url": "https://github.com/pengwynn/ujs_sort_helper.git",
|
18
|
+
"open_issues_count": 1,
|
19
|
+
"updated_at": "2012-09-10T04:46:49Z",
|
20
|
+
"html_url": "https://github.com/pengwynn/ujs_sort_helper",
|
21
|
+
"open_issues": 1,
|
22
|
+
"ssh_url": "git@github.com:pengwynn/ujs_sort_helper.git",
|
23
|
+
"size": 140,
|
24
|
+
"fork": false,
|
25
|
+
"pushed_at": "2011-10-14T13:14:06Z",
|
26
|
+
"full_name": "pengwynn/ujs_sort_helper",
|
27
|
+
"name": "ujs_sort_helper",
|
28
|
+
"forks": 8,
|
29
|
+
"has_issues": true,
|
30
|
+
"has_downloads": true,
|
31
|
+
"forks_count": 8,
|
32
|
+
"mirror_url": null,
|
33
|
+
"private": false,
|
34
|
+
"id": 11560,
|
35
|
+
"created_at": "2008-04-21T15:55:02Z",
|
36
|
+
"git_url": "git://github.com/pengwynn/ujs_sort_helper.git",
|
37
|
+
"homepage": ""
|
38
|
+
}
|
39
|
+
]
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
data/spec/helper.rb
CHANGED
@@ -43,6 +43,10 @@ def stub_get(url)
|
|
43
43
|
stub_request(:get, github_url(url))
|
44
44
|
end
|
45
45
|
|
46
|
+
def stub_head(url)
|
47
|
+
stub_request(:head, github_url(url))
|
48
|
+
end
|
49
|
+
|
46
50
|
def stub_patch(url)
|
47
51
|
stub_request(:patch, github_url(url))
|
48
52
|
end
|
@@ -63,13 +67,20 @@ def fixture(file)
|
|
63
67
|
File.new(fixture_path + '/' + file)
|
64
68
|
end
|
65
69
|
|
70
|
+
def json_response(file)
|
71
|
+
{
|
72
|
+
:body => fixture(file),
|
73
|
+
:headers => {
|
74
|
+
:content_type => 'application/json; charset=utf-8'
|
75
|
+
}
|
76
|
+
}
|
77
|
+
end
|
78
|
+
|
66
79
|
def github_url(url)
|
67
80
|
if url =~ /^http/
|
68
81
|
url
|
69
82
|
elsif @client && @client.authenticated?
|
70
83
|
"https://#{@client.login}:#{@client.password}@api.github.com#{url}"
|
71
|
-
elsif @client && @client.oauthed?
|
72
|
-
"https://api.github.com#{url}?access_token=#{@client.oauth_token}"
|
73
84
|
else
|
74
85
|
"https://api.github.com#{url}"
|
75
86
|
end
|
@@ -10,14 +10,14 @@ describe Octokit::Client::Authorizations do
|
|
10
10
|
|
11
11
|
it "lists existing authorizations" do
|
12
12
|
stub_get("/authorizations").
|
13
|
-
to_return(
|
13
|
+
to_return(json_response("authorizations.json"))
|
14
14
|
authorizations = @client.authorizations
|
15
15
|
expect(authorizations.first.app.name).to eq("Calendar About Nothing" )
|
16
16
|
end
|
17
17
|
|
18
18
|
it "returns a single authorization" do
|
19
19
|
stub_get("/authorizations/999999").
|
20
|
-
to_return(
|
20
|
+
to_return(json_response("authorization.json"))
|
21
21
|
authorization = @client.authorization(999999)
|
22
22
|
expect(authorization.app.name).to eq("Travis" )
|
23
23
|
end
|
@@ -26,7 +26,7 @@ describe Octokit::Client::Authorizations do
|
|
26
26
|
stub_post('/authorizations').
|
27
27
|
with(:body => {"scopes" => ""},
|
28
28
|
:headers => {'Content-Type'=>'application/json'}).
|
29
|
-
to_return(
|
29
|
+
to_return(json_response("authorization.json"))
|
30
30
|
authorization = @client.create_authorization
|
31
31
|
expect(authorization.app.name).to eq("Travis" )
|
32
32
|
end
|
@@ -35,7 +35,7 @@ describe Octokit::Client::Authorizations do
|
|
35
35
|
stub_post('/authorizations').
|
36
36
|
with(:body => {"scopes" => ["public_repo"],"note" => "admin script", "note_url" => "https://github.com/pengwynn/octokit"},
|
37
37
|
:headers => {'Content-Type'=>'application/json'}).
|
38
|
-
to_return(
|
38
|
+
to_return(json_response("authorization.json"))
|
39
39
|
authorization = @client.create_authorization({:scopes => ["public_repo"], :note => "admin script", :note_url => "https://github.com/pengwynn/octokit"})
|
40
40
|
expect(authorization.scopes).to include("public_repo")
|
41
41
|
end
|
@@ -44,7 +44,7 @@ describe Octokit::Client::Authorizations do
|
|
44
44
|
stub_patch('/authorizations/999999').
|
45
45
|
with(:body => {"scopes"=>"", "add_scopes" => ["public_repo", "gist"]},
|
46
46
|
:headers => {'Content-Type'=>'application/json'}).
|
47
|
-
to_return(
|
47
|
+
to_return(json_response("authorization.json"))
|
48
48
|
authorization = @client.update_authorization(999999, {:add_scopes => ['public_repo', 'gist']})
|
49
49
|
expect(authorization.scopes).to include("public_repo")
|
50
50
|
end
|
@@ -52,8 +52,45 @@ describe Octokit::Client::Authorizations do
|
|
52
52
|
it "deletes an existing authorization" do
|
53
53
|
stub_delete('/authorizations/999999').
|
54
54
|
to_return(:status => 204)
|
55
|
-
|
56
|
-
expect(
|
55
|
+
result = @client.delete_authorization(999999)
|
56
|
+
expect(result).to be_true
|
57
|
+
end
|
58
|
+
|
59
|
+
context "when working with tokens" do
|
60
|
+
before(:each) do
|
61
|
+
Octokit.reset
|
62
|
+
end
|
63
|
+
|
64
|
+
it "checks the scopes on a token" do
|
65
|
+
stub_get("https://api.github.com/user").
|
66
|
+
to_return \
|
67
|
+
:status => 200,
|
68
|
+
:body => fixture('user.json'),
|
69
|
+
:headers => {
|
70
|
+
:content_type => 'application/json; charset=utf-8',
|
71
|
+
:x_oauth_scopes => 'user, gist'
|
72
|
+
}
|
73
|
+
|
74
|
+
client = Octokit::Client.new :oauth_token => 'abcdabcdabcdabcdabcdabcdabcdabcdabcd'
|
75
|
+
scopes = Octokit.scopes
|
76
|
+
expect(scopes).to eq(['gist', 'user'])
|
77
|
+
end
|
78
|
+
|
79
|
+
it "checks the scopes on a one-off token" do
|
80
|
+
stub_get("https://api.github.com/user").
|
81
|
+
to_return \
|
82
|
+
:status => 200,
|
83
|
+
:body => fixture('user.json'),
|
84
|
+
:headers => {
|
85
|
+
:content_type => 'application/json; charset=utf-8',
|
86
|
+
:x_oauth_scopes => 'user, gist, repo'
|
87
|
+
}
|
88
|
+
|
89
|
+
client = Octokit::Client.new
|
90
|
+
scopes = Octokit.scopes('abcdabcdabcdabcdabcdabcdabcdabcdabcd')
|
91
|
+
expect(scopes).to eq(['gist', 'repo', 'user'])
|
92
|
+
end
|
93
|
+
|
57
94
|
end
|
58
95
|
|
59
96
|
end
|
@@ -1,6 +1,10 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
require 'helper'
|
3
3
|
|
4
|
+
# need this to filter the data
|
5
|
+
require 'json'
|
6
|
+
require 'date'
|
7
|
+
|
4
8
|
describe Octokit::Client::Commits do
|
5
9
|
|
6
10
|
before do
|
@@ -11,18 +15,139 @@ describe Octokit::Client::Commits do
|
|
11
15
|
|
12
16
|
it "returns all commits" do
|
13
17
|
stub_get("/repos/sferik/rails_admin/commits?per_page=35&sha=master").
|
14
|
-
to_return(
|
18
|
+
to_return(json_response("commits.json"))
|
15
19
|
commits = @client.commits("sferik/rails_admin")
|
16
20
|
expect(commits.first.author.login).to eq("caboteria")
|
17
21
|
end
|
18
22
|
|
19
23
|
end
|
20
24
|
|
25
|
+
describe ".commits_on" do
|
26
|
+
|
27
|
+
it "returns all commits on the specified date" do
|
28
|
+
stub_http_request(:get, "https://api.github.com/repos/sferik/rails_admin/commits").
|
29
|
+
with(:query=>{"per_page" => 35, "sha" => "master",
|
30
|
+
"since" => "2011-01-20T00:00:00+00:00", "until" => "2011-01-21T00:00:00+00:00"}).
|
31
|
+
to_return json_response('commits.json')
|
32
|
+
commits = @client.commits_on("sferik/rails_admin", "2011-01-20")
|
33
|
+
expect(commits).to be_an(Array)
|
34
|
+
end
|
35
|
+
|
36
|
+
it "returns an empty array if there are no commits on the specified date" do
|
37
|
+
stub_http_request(:get, "https://api.github.com/repos/sferik/rails_admin/commits").
|
38
|
+
with(:query=>{"per_page" => 35, "sha" => "master",
|
39
|
+
"since" => "2011-01-15T00:00:00+00:00",
|
40
|
+
"until" => "2011-01-16T00:00:00+00:00"}).
|
41
|
+
to_return json_response('commits.json')
|
42
|
+
commits = @client.commits_on("sferik/rails_admin", "2011-01-15")
|
43
|
+
expect(commits).to be_an(Array)
|
44
|
+
end
|
45
|
+
|
46
|
+
it "errors if the date is invalid" do
|
47
|
+
expect {@client.commits_on("sferik/rails_admin", "A pear")}.to raise_exception(ArgumentError, "A pear is not a valid date")
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
|
52
|
+
describe ".commits_since" do
|
53
|
+
|
54
|
+
it "returns all commits after the specified date" do
|
55
|
+
start_date = Date.parse("2011-01-16T00:00:00+00:00")
|
56
|
+
stub_http_request(:get, "https://api.github.com/repos/sferik/rails_admin/commits").
|
57
|
+
with(:query=>{"per_page" => 35, "sha" => "master",
|
58
|
+
"since" => "2011-01-16T00:00:00+00:00"}).
|
59
|
+
to_return json_response('commits.json')
|
60
|
+
commits = @client.commits_since("sferik/rails_admin", "2011-01-16")
|
61
|
+
expect(commits).to be_an(Array)
|
62
|
+
end
|
63
|
+
|
64
|
+
it "returns an empty array if there are no commits after the specified date" do
|
65
|
+
start_date = Date.parse("2011-01-22T00:00:00+00:00")
|
66
|
+
stub_http_request(:get, "https://api.github.com/repos/sferik/rails_admin/commits").
|
67
|
+
with(:query=>{"per_page" => 35, "sha" => "master",
|
68
|
+
"since" => "2011-01-22T00:00:00+00:00"}).
|
69
|
+
to_return json_response('commits.json')
|
70
|
+
commits = @client.commits_since("sferik/rails_admin", "2011-01-22")
|
71
|
+
expect(commits).to be_an(Array)
|
72
|
+
end
|
73
|
+
|
74
|
+
it "errors if the date is invalid" do
|
75
|
+
expect {@client.commits_since("sferik/rails_admin", "A pear")}.to raise_exception(ArgumentError, "A pear is not a valid date")
|
76
|
+
end
|
77
|
+
|
78
|
+
end
|
79
|
+
|
80
|
+
describe ".commits_before" do
|
81
|
+
|
82
|
+
it "returns all commits before the specified date" do
|
83
|
+
end_date = Date.parse("2011-01-17T00:00:00+00:00")
|
84
|
+
stub_http_request(:get, "https://api.github.com/repos/sferik/rails_admin/commits").
|
85
|
+
with(:query=>{"per_page" => 35, "sha" => "master",
|
86
|
+
"until" => "2011-01-17T00:00:00+00:00"}).
|
87
|
+
to_return json_response('commits.json')
|
88
|
+
commits = @client.commits_before("sferik/rails_admin", "2011-01-17")
|
89
|
+
expect(commits).to be_an(Array)
|
90
|
+
end
|
91
|
+
|
92
|
+
it "returns an empty array if there are no commits before the specified date" do
|
93
|
+
end_date = DateTime.parse("2011-01-16T00:00:00%2000:00")
|
94
|
+
stub_http_request(:get, "https://api.github.com/repos/sferik/rails_admin/commits").
|
95
|
+
with(:query=>{"per_page" => 35, "sha" => "master",
|
96
|
+
"until" => "2011-01-16T00:00:00+00:00"}).
|
97
|
+
to_return json_response('commits.json')
|
98
|
+
commits = @client.commits_before("sferik/rails_admin", "2011-01-16")
|
99
|
+
expect(commits).to be_an(Array)
|
100
|
+
end
|
101
|
+
|
102
|
+
it "errors if the date is invalid" do
|
103
|
+
expect {@client.commits_before("sferik/rails_admin", "A pear")}.to raise_exception(ArgumentError, "A pear is not a valid date")
|
104
|
+
end
|
105
|
+
|
106
|
+
end
|
107
|
+
|
108
|
+
describe ".commits_between" do
|
109
|
+
|
110
|
+
it "returns all commits between the specified dates" do
|
111
|
+
start_date = DateTime.parse("2011-01-17T00:00:00+00:00")
|
112
|
+
end_date = DateTime.parse("2011-01-20T00:00:00+00:00")
|
113
|
+
stub_http_request(:get, "https://api.github.com/repos/sferik/rails_admin/commits").
|
114
|
+
with(:query=>{"per_page" => 35, "sha" => "master",
|
115
|
+
"since" => "2011-01-17T00:00:00+00:00", "until" => "2011-01-20T00:00:00+00:00"}).
|
116
|
+
to_return json_response('commits.json')
|
117
|
+
commits = @client.commits_between("sferik/rails_admin", "2011-01-17", "2011-01-20")
|
118
|
+
expect(commits).to be_an(Array)
|
119
|
+
end
|
120
|
+
|
121
|
+
it "returns an empty array if there are no commits between the specified dates" do
|
122
|
+
start_date = Date.parse("2011-01-15T00:00:00+00:00")
|
123
|
+
end_date = Date.parse("2011-01-16T00:00:00+00:00")
|
124
|
+
stub_http_request(:get, "https://api.github.com/repos/sferik/rails_admin/commits").
|
125
|
+
with(:query=>{"per_page" => 35, "sha" => "master",
|
126
|
+
"since" => "2011-01-15T00:00:00+00:00", "until" => "2011-01-16T00:00:00+00:00"}).
|
127
|
+
to_return json_response('commits.json')
|
128
|
+
commits = @client.commits_between("sferik/rails_admin", "2011-01-15", "2011-01-16")
|
129
|
+
expect(commits).to be_an(Array)
|
130
|
+
end
|
131
|
+
|
132
|
+
it "errors if the end_date preceeds the start_date" do
|
133
|
+
expect {@client.commits_between("sferik/rails_admin", "2011-01-16", "2011-01-15")}.to raise_exception(ArgumentError, "Start date 2011-01-16 does not precede 2011-01-15")
|
134
|
+
end
|
135
|
+
|
136
|
+
it "errors if the start date is invalid" do
|
137
|
+
expect {@client.commits_between("sferik/rails_admin", "A pear", "2011-01-15")}.to raise_exception(ArgumentError, "A pear is not a valid date")
|
138
|
+
end
|
139
|
+
|
140
|
+
it "errors if the end date is invalid" do
|
141
|
+
expect {@client.commits_between("sferik/rails_admin", "2011-01-16", "A walrus")}.to raise_exception(ArgumentError, "A walrus is not a valid date")
|
142
|
+
end
|
143
|
+
|
144
|
+
end
|
145
|
+
|
21
146
|
describe ".commit" do
|
22
147
|
|
23
148
|
it "returns a commit" do
|
24
149
|
stub_get("/repos/sferik/rails_admin/commits/3cdfabd973bc3caac209cba903cfdb3bf6636bcd").
|
25
|
-
to_return(
|
150
|
+
to_return(json_response("commit.json"))
|
26
151
|
commit = @client.commit("sferik/rails_admin", "3cdfabd973bc3caac209cba903cfdb3bf6636bcd")
|
27
152
|
expect(commit.author.login).to eq("caboteria")
|
28
153
|
end
|
@@ -35,7 +160,7 @@ describe Octokit::Client::Commits do
|
|
35
160
|
stub_post("/repos/octocat/Hello-World/git/commits").
|
36
161
|
with(:body => { :message => "My commit message", :tree => "827efc6d56897b048c772eb4087f854f46256132", :parents => ["7d1b31e74ee336d15cbd21741bc88a537ed063a0"] },
|
37
162
|
:headers => { "Content-Type" => "application/json" }).
|
38
|
-
to_return(
|
163
|
+
to_return(json_response("commit_create.json"))
|
39
164
|
commit = @client.create_commit("octocat/Hello-World", "My commit message", "827efc6d56897b048c772eb4087f854f46256132", "7d1b31e74ee336d15cbd21741bc88a537ed063a0")
|
40
165
|
expect(commit.sha).to eq("7638417db6d59f3c431d3e1f261cc637155684cd")
|
41
166
|
expect(commit.message).to eq("My commit message")
|
@@ -49,7 +174,7 @@ describe Octokit::Client::Commits do
|
|
49
174
|
|
50
175
|
it "returns a list of all commit comments" do
|
51
176
|
stub_get("/repos/sferik/rails_admin/comments").
|
52
|
-
to_return(
|
177
|
+
to_return(json_response("list_commit_comments.json"))
|
53
178
|
commit_comments = @client.list_commit_comments("sferik/rails_admin")
|
54
179
|
expect(commit_comments.first.user.login).to eq("sferik")
|
55
180
|
end
|
@@ -60,7 +185,7 @@ describe Octokit::Client::Commits do
|
|
60
185
|
|
61
186
|
it "returns a list of comments for a specific commit" do
|
62
187
|
stub_get("/repos/sferik/rails_admin/commits/629e9fd9d4df25528e84d31afdc8ebeb0f56fbb3/comments").
|
63
|
-
to_return(
|
188
|
+
to_return(json_response("commit_comments.json"))
|
64
189
|
commit_comments = @client.commit_comments("sferik/rails_admin", "629e9fd9d4df25528e84d31afdc8ebeb0f56fbb3")
|
65
190
|
expect(commit_comments.first.user.login).to eq("bbenezech")
|
66
191
|
end
|
@@ -71,7 +196,7 @@ describe Octokit::Client::Commits do
|
|
71
196
|
|
72
197
|
it "returns a single commit comment" do
|
73
198
|
stub_get("/repos/sferik/rails_admin/comments/861907").
|
74
|
-
to_return(
|
199
|
+
to_return(json_response("commit_comment.json"))
|
75
200
|
commit = @client.commit_comment("sferik/rails_admin", "861907")
|
76
201
|
expect(commit.user.login).to eq("bbenezech")
|
77
202
|
end
|
@@ -84,7 +209,7 @@ describe Octokit::Client::Commits do
|
|
84
209
|
stub_post("/repos/sferik/rails_admin/commits/629e9fd9d4df25528e84d31afdc8ebeb0f56fbb3/comments").
|
85
210
|
with(:body => { :body => "Hey Eric,\r\n\r\nI think it's a terrible idea: for a number of reasons (dissections, etc.), test suite should stay deterministic IMO.\r\n", :commit_id => "629e9fd9d4df25528e84d31afdc8ebeb0f56fbb3", :line => 1, :path => ".rspec", :position => 4 },
|
86
211
|
:headers => { "Content-Type" => "application/json" }).
|
87
|
-
to_return(
|
212
|
+
to_return(json_response("commit_comment_create.json"))
|
88
213
|
commit_comment = @client.create_commit_comment("sferik/rails_admin", "629e9fd9d4df25528e84d31afdc8ebeb0f56fbb3", "Hey Eric,\r\n\r\nI think it's a terrible idea: for a number of reasons (dissections, etc.), test suite should stay deterministic IMO.\r\n", ".rspec", 1, 4)
|
89
214
|
expect(commit_comment.body).to eq("Hey Eric,\r\n\r\nI think it's a terrible idea: for a number of reasons (dissections, etc.), test suite should stay deterministic IMO.\r\n")
|
90
215
|
expect(commit_comment.commit_id).to eq("629e9fd9d4df25528e84d31afdc8ebeb0f56fbb3")
|
@@ -101,7 +226,7 @@ describe Octokit::Client::Commits do
|
|
101
226
|
stub_patch("/repos/sferik/rails_admin/comments/860296").
|
102
227
|
with(:body => { :body => "Hey Eric,\r\n\r\nI think it's a terrible idea. The test suite should stay deterministic IMO.\r\n" },
|
103
228
|
:headers => { "Content-Type" => "application/json" }).
|
104
|
-
to_return(
|
229
|
+
to_return(json_response("commit_comment_update.json"))
|
105
230
|
commit_comment = @client.update_commit_comment("sferik/rails_admin", "860296", "Hey Eric,\r\n\r\nI think it's a terrible idea. The test suite should stay deterministic IMO.\r\n")
|
106
231
|
expect(commit_comment.body).to eq("Hey Eric,\r\n\r\nI think it's a terrible idea. The test suite should stay deterministic IMO.\r\n")
|
107
232
|
end
|
@@ -114,7 +239,7 @@ describe Octokit::Client::Commits do
|
|
114
239
|
stub_delete("/repos/sferik/rails_admin/comments/860296").
|
115
240
|
to_return(:status => 204, :body => "")
|
116
241
|
commit_comment = @client.delete_commit_comment("sferik/rails_admin", "860296")
|
117
|
-
expect(commit_comment).to
|
242
|
+
expect(commit_comment).to be_true
|
118
243
|
end
|
119
244
|
|
120
245
|
end
|
@@ -123,7 +248,7 @@ describe Octokit::Client::Commits do
|
|
123
248
|
|
124
249
|
it "returns a comparison" do
|
125
250
|
stub_get("/repos/gvaughn/octokit/compare/0e0d7ae299514da692eb1cab741562c253d44188...b7b37f75a80b8e84061cd45b246232ad958158f5").
|
126
|
-
to_return(
|
251
|
+
to_return(json_response("compare.json"))
|
127
252
|
comparison = @client.compare("gvaughn/octokit", '0e0d7ae299514da692eb1cab741562c253d44188', 'b7b37f75a80b8e84061cd45b246232ad958158f5')
|
128
253
|
expect(comparison.base_commit.sha).to eq('0e0d7ae299514da692eb1cab741562c253d44188')
|
129
254
|
expect(comparison.merge_base_commit.sha).to eq('b7b37f75a80b8e84061cd45b246232ad958158f5')
|
@@ -134,7 +259,7 @@ describe Octokit::Client::Commits do
|
|
134
259
|
|
135
260
|
before do
|
136
261
|
stub_post("/repos/pengwynn/api-sandbox/merges").
|
137
|
-
to_return(
|
262
|
+
to_return(json_response("merge.json"))
|
138
263
|
end
|
139
264
|
|
140
265
|
it "merges a branch into another" do
|