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
@@ -11,7 +11,7 @@ describe Octokit::Client::Markdown do
|
|
11
11
|
|
12
12
|
it "renders markdown" do
|
13
13
|
stub_post("/markdown").
|
14
|
-
to_return(:body => fixture("
|
14
|
+
to_return(:body => fixture("markdown_gfm"))
|
15
15
|
text = "This is for #111"
|
16
16
|
markdown = @client.markdown(text, :context => 'pengwynn/octokit', :mode => 'gfm')
|
17
17
|
|
@@ -11,7 +11,7 @@ describe Octokit::Client::Milestones do
|
|
11
11
|
|
12
12
|
it "lists milestones belonging to repository" do
|
13
13
|
stub_get("/repos/pengwynn/octokit/milestones").
|
14
|
-
to_return(
|
14
|
+
to_return(json_response('milestones.json'))
|
15
15
|
milestones = @client.list_milestones("pengwynn/octokit")
|
16
16
|
expect(milestones.first.description).to eq("Add support for API v3")
|
17
17
|
end
|
@@ -22,7 +22,7 @@ describe Octokit::Client::Milestones do
|
|
22
22
|
|
23
23
|
it "gets a single milestone belonging to repository" do
|
24
24
|
stub_get("/repos/pengwynn/octokit/milestones/1").
|
25
|
-
to_return(
|
25
|
+
to_return(json_response('milestone.json'))
|
26
26
|
milestones = @client.milestone("pengwynn/octokit", 1)
|
27
27
|
expect(milestones.description).to eq("Add support for API v3")
|
28
28
|
end
|
@@ -33,8 +33,8 @@ describe Octokit::Client::Milestones do
|
|
33
33
|
|
34
34
|
it "creates a single milestone" do
|
35
35
|
stub_post("/repos/pengwynn/octokit/milestones").
|
36
|
-
with(:body => '{"title":"0.7.0"}'
|
37
|
-
to_return(
|
36
|
+
with(:body => '{"title":"0.7.0"}').
|
37
|
+
to_return(json_response('milestone.json'))
|
38
38
|
milestone = @client.create_milestone("pengwynn/octokit", "0.7.0")
|
39
39
|
expect(milestone.title).to eq("0.7.0")
|
40
40
|
end
|
@@ -45,8 +45,8 @@ describe Octokit::Client::Milestones do
|
|
45
45
|
|
46
46
|
it "updates a milestone" do
|
47
47
|
stub_post("/repos/pengwynn/octokit/milestones/1").
|
48
|
-
with(:body => {"description" => "Add support for API v3"}
|
49
|
-
to_return(
|
48
|
+
with(:body => {"description" => "Add support for API v3"}).
|
49
|
+
to_return(json_response('milestone.json'))
|
50
50
|
milestone = @client.update_milestone("pengwynn/octokit", 1, {:description => "Add support for API v3"})
|
51
51
|
expect(milestone.description).to eq("Add support for API v3")
|
52
52
|
end
|
@@ -58,8 +58,8 @@ describe Octokit::Client::Milestones do
|
|
58
58
|
it "deletes a milestone from a repository" do
|
59
59
|
stub_delete("/repos/pengwynn/octokit/milestones/2").
|
60
60
|
to_return(:status => 204, :body => "", :headers => {})
|
61
|
-
|
62
|
-
expect(
|
61
|
+
result = @client.delete_milestone("pengwynn/octokit", 2)
|
62
|
+
expect(result).to be_true
|
63
63
|
end
|
64
64
|
|
65
65
|
end
|
@@ -0,0 +1,141 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require 'helper'
|
3
|
+
|
4
|
+
describe Octokit::Client::Notifications do
|
5
|
+
|
6
|
+
before do
|
7
|
+
@client = Octokit::Client.new(:login => "joeyw")
|
8
|
+
end
|
9
|
+
|
10
|
+
describe ".notifications" do
|
11
|
+
|
12
|
+
it "lists the notifications for the current user" do
|
13
|
+
stub_get("https://api.github.com/notifications").
|
14
|
+
to_return(json_response("notifications.json"))
|
15
|
+
notifications = @client.notifications
|
16
|
+
expect(notifications.first.id).to eq(1)
|
17
|
+
expect(notifications.first.unread).to be_true
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
describe ".repository_notifications" do
|
23
|
+
|
24
|
+
it "lists all notifications for a repository" do
|
25
|
+
stub_get("https://api.github.com/repos/pengwynn/octokit/notifications").
|
26
|
+
to_return(json_response("repository_notifications.json"))
|
27
|
+
notifications = @client.repository_notifications("pengwynn/octokit")
|
28
|
+
expect(notifications.first.id).to eq(1)
|
29
|
+
expect(notifications.first.unread).to be_true
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
describe ".mark_notifications_as_read" do
|
35
|
+
|
36
|
+
it "returns true when notifications are marked as read" do
|
37
|
+
stub_put("https://api.github.com/notifications").
|
38
|
+
to_return(:status => 205)
|
39
|
+
result = @client.mark_notifications_as_read
|
40
|
+
expect(result).to be_true
|
41
|
+
end
|
42
|
+
|
43
|
+
it "returns false when unsuccessful" do
|
44
|
+
stub_put("https://api.github.com/notifications").
|
45
|
+
to_return(:status => 500)
|
46
|
+
result = @client.mark_notifications_as_read
|
47
|
+
expect(result).to be_false
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
|
52
|
+
describe ".mark_repository_notifications_as_read" do
|
53
|
+
|
54
|
+
it "returns true when notifications for a repo are marked as read" do
|
55
|
+
stub_put("https://api.github.com/repos/pengwynn/octokit/notifications").
|
56
|
+
to_return(:status => 205)
|
57
|
+
result = @client.mark_repository_notifications_as_read("pengwynn/octokit")
|
58
|
+
expect(result).to be_true
|
59
|
+
end
|
60
|
+
|
61
|
+
it "returns false when unsuccessful" do
|
62
|
+
stub_put("https://api.github.com/repos/pengwynn/octokit/notifications").
|
63
|
+
to_return(:status => 500)
|
64
|
+
result = @client.mark_repository_notifications_as_read("pengwynn/octokit")
|
65
|
+
expect(result).to be_false
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
69
|
+
|
70
|
+
describe ".thread_notifications" do
|
71
|
+
|
72
|
+
it "returns notifications for a specific thread" do
|
73
|
+
stub_get("https://api.github.com/notifications/threads/1").
|
74
|
+
to_return(json_response('notification_thread.json'))
|
75
|
+
notifications = @client.thread_notifications(1)
|
76
|
+
expect(notifications.first.id).to eq(1)
|
77
|
+
expect(notifications.first.unread).to be_true
|
78
|
+
end
|
79
|
+
|
80
|
+
end
|
81
|
+
|
82
|
+
describe ".mark_thread_as_read" do
|
83
|
+
|
84
|
+
it "marks a thread as read" do
|
85
|
+
stub_patch("https://api.github.com/notifications/threads/1").
|
86
|
+
to_return(:status => 205)
|
87
|
+
result = @client.mark_thread_as_read(1)
|
88
|
+
expect(result).to be_true
|
89
|
+
end
|
90
|
+
|
91
|
+
it "returns false when unsuccessful" do
|
92
|
+
stub_patch("https://api.github.com/notifications/threads/1").
|
93
|
+
to_return(:status => 500)
|
94
|
+
result = @client.mark_thread_as_read(1)
|
95
|
+
expect(result).to be_false
|
96
|
+
end
|
97
|
+
|
98
|
+
end
|
99
|
+
|
100
|
+
describe ".thread_subscription" do
|
101
|
+
|
102
|
+
it "returns a thread subscription" do
|
103
|
+
stub_get("https://api.github.com/notifications/threads/1/subscription").
|
104
|
+
to_return(json_response("thread_subscription.json"))
|
105
|
+
subscription = @client.thread_subscription(1)
|
106
|
+
expect(subscription.subscribed).to be_true
|
107
|
+
end
|
108
|
+
|
109
|
+
end
|
110
|
+
|
111
|
+
describe ".update_thread_subscription" do
|
112
|
+
|
113
|
+
it "updates a thread subscription" do
|
114
|
+
stub_put("https://api.github.com/notifications/threads/1/subscription").
|
115
|
+
to_return(json_response("thread_subscription_update.json"))
|
116
|
+
subscription = @client.update_thread_subscription(1, :subscribed => true)
|
117
|
+
expect(subscription.subscribed).to be_true
|
118
|
+
end
|
119
|
+
|
120
|
+
end
|
121
|
+
|
122
|
+
describe ".delete_thread_subscription" do
|
123
|
+
|
124
|
+
it "returns true with successful thread deletion" do
|
125
|
+
stub_delete("https://api.github.com/notifications/threads/1").
|
126
|
+
to_return(:status => 204)
|
127
|
+
result = @client.delete_thread_subscription(1)
|
128
|
+
expect(result).to be_true
|
129
|
+
end
|
130
|
+
|
131
|
+
it "returns false when subscription deletion fails" do
|
132
|
+
stub_delete("https://api.github.com/notifications/threads/1").
|
133
|
+
to_return(:status => 500)
|
134
|
+
result = @client.delete_thread_subscription(1)
|
135
|
+
expect(result).to be_false
|
136
|
+
end
|
137
|
+
|
138
|
+
|
139
|
+
end
|
140
|
+
|
141
|
+
end
|
@@ -11,7 +11,7 @@ describe Octokit::Client::Objects do
|
|
11
11
|
|
12
12
|
it "returns a tree" do
|
13
13
|
stub_get("https://api.github.com/repos/sferik/rails_admin/git/trees/3cdfabd973bc3caac209cba903cfdb3bf6636bcd").
|
14
|
-
to_return(
|
14
|
+
to_return(json_response("tree.json"))
|
15
15
|
result = @client.tree("sferik/rails_admin", "3cdfabd973bc3caac209cba903cfdb3bf6636bcd")
|
16
16
|
expect(result.sha).to eq("3cdfabd973bc3caac209cba903cfdb3bf6636bcd")
|
17
17
|
expect(result.tree.first.path).to eq(".gitignore")
|
@@ -25,7 +25,7 @@ describe Octokit::Client::Objects do
|
|
25
25
|
stub_post("/repos/octocat/Hello-World/git/trees").
|
26
26
|
with(:body => { :tree => [ { :path => "file.rb", "mode" => "100644", "type" => "blob", "sha" => "44b4fc6d56897b048c772eb4087f854f46256132" } ] },
|
27
27
|
:headers => { "Content-Type" => "application/json" }).
|
28
|
-
to_return(
|
28
|
+
to_return(json_response("tree_create.json"))
|
29
29
|
response = @client.create_tree("octocat/Hello-World", [ { "path" => "file.rb", "mode" => "100644", "type" => "blob", "sha" => "44b4fc6d56897b048c772eb4087f854f46256132" } ])
|
30
30
|
expect(response.sha).to eq("cd8274d15fa3ae2ab983129fb037999f264ba9a7")
|
31
31
|
expect(response.tree.size).to eq(1)
|
@@ -38,7 +38,7 @@ describe Octokit::Client::Objects do
|
|
38
38
|
|
39
39
|
it "returns a blob" do
|
40
40
|
stub_get("https://api.github.com/repos/sferik/rails_admin/git/blobs/94616fa57520ac8147522c7cf9f03d555595c5ea").
|
41
|
-
to_return(
|
41
|
+
to_return(json_response("blob.json"))
|
42
42
|
blob = @client.blob("sferik/rails_admin", "94616fa57520ac8147522c7cf9f03d555595c5ea")
|
43
43
|
expect(blob.sha).to eq("94616fa57520ac8147522c7cf9f03d555595c5ea")
|
44
44
|
end
|
@@ -51,7 +51,7 @@ describe Octokit::Client::Objects do
|
|
51
51
|
stub_post("/repos/octocat/Hello-World/git/blobs").
|
52
52
|
with(:body => { :content => "content", :encoding => "utf-8" },
|
53
53
|
:headers => { "Content-Type" => "application/json" }).
|
54
|
-
to_return(
|
54
|
+
to_return(json_response("blob_create.json"))
|
55
55
|
blob = @client.create_blob("octocat/Hello-World", "content")
|
56
56
|
expect(blob).to eq("3a0f86fb8db8eea7ccbb9a95f325ddbedfb25e15")
|
57
57
|
end
|
@@ -62,7 +62,7 @@ describe Octokit::Client::Objects do
|
|
62
62
|
|
63
63
|
it "returns a tag" do
|
64
64
|
stub_get("/repos/pengwynn/octokit/git/tags/23aad20633f4d2981b1c7209a800db3014774e96").
|
65
|
-
to_return(
|
65
|
+
to_return(json_response("tag.json"))
|
66
66
|
tag = @client.tag("pengwynn/octokit", "23aad20633f4d2981b1c7209a800db3014774e96")
|
67
67
|
expect(tag.sha).to eq("23aad20633f4d2981b1c7209a800db3014774e96")
|
68
68
|
expect(tag.message).to eq("Version 1.4.0\n")
|
@@ -87,7 +87,7 @@ describe Octokit::Client::Objects do
|
|
87
87
|
}
|
88
88
|
},
|
89
89
|
:headers => { "Content-Type" => "application/json" }).
|
90
|
-
to_return(
|
90
|
+
to_return(json_response("tag_create.json"))
|
91
91
|
tag = @client.create_tag(
|
92
92
|
"pengwynn/octokit",
|
93
93
|
"v9000.0.0",
|
@@ -11,7 +11,7 @@ describe Octokit::Client::Organizations do
|
|
11
11
|
|
12
12
|
it "returns an organization" do
|
13
13
|
stub_get("https://api.github.com/orgs/codeforamerica").
|
14
|
-
to_return(
|
14
|
+
to_return(json_response("organization.json"))
|
15
15
|
organization = @client.organization("codeforamerica")
|
16
16
|
expect(organization.name).to eq("Code For America")
|
17
17
|
end
|
@@ -23,7 +23,7 @@ describe Octokit::Client::Organizations do
|
|
23
23
|
it "updates an organization" do
|
24
24
|
stub_patch("https://api.github.com/orgs/codeforamerica").
|
25
25
|
with(:name => "Code For America").
|
26
|
-
to_return(
|
26
|
+
to_return(json_response("organization.json"))
|
27
27
|
organization = @client.update_organization("codeforamerica", {:name => "Code For America"})
|
28
28
|
expect(organization.name).to eq("Code For America")
|
29
29
|
end
|
@@ -36,7 +36,7 @@ describe Octokit::Client::Organizations do
|
|
36
36
|
|
37
37
|
it "returns all organizations for a user" do
|
38
38
|
stub_get("https://api.github.com/users/sferik/orgs").
|
39
|
-
to_return(
|
39
|
+
to_return(json_response("organizations.json"))
|
40
40
|
organizations = @client.organizations("sferik")
|
41
41
|
expect(organizations.first.login).to eq("Hubcap")
|
42
42
|
end
|
@@ -47,7 +47,7 @@ describe Octokit::Client::Organizations do
|
|
47
47
|
|
48
48
|
it "returns all organizations for a user" do
|
49
49
|
stub_get("https://api.github.com/user/orgs").
|
50
|
-
to_return(
|
50
|
+
to_return(json_response("organizations.json"))
|
51
51
|
organizations = @client.organizations
|
52
52
|
expect(organizations.first.login).to eq("Hubcap")
|
53
53
|
end
|
@@ -60,7 +60,7 @@ describe Octokit::Client::Organizations do
|
|
60
60
|
|
61
61
|
it "returns all public repositories for an organization" do
|
62
62
|
stub_get("https://api.github.com/orgs/codeforamerica/repos").
|
63
|
-
to_return(
|
63
|
+
to_return(json_response("organization-repositories.json"))
|
64
64
|
repositories = @client.organization_repositories("codeforamerica")
|
65
65
|
expect(repositories.first.name).to eq("cfahelloworld")
|
66
66
|
end
|
@@ -71,18 +71,70 @@ describe Octokit::Client::Organizations do
|
|
71
71
|
|
72
72
|
it "returns all public members of an organization" do
|
73
73
|
stub_get("https://api.github.com/orgs/codeforamerica/members").
|
74
|
-
to_return(
|
74
|
+
to_return(json_response("organization_members.json"))
|
75
75
|
users = @client.organization_members("codeforamerica")
|
76
76
|
expect(users.first.login).to eq("akit")
|
77
77
|
end
|
78
78
|
|
79
79
|
end
|
80
80
|
|
81
|
+
describe ".organization_member?" do
|
82
|
+
|
83
|
+
context "user is actually a member of the organization" do
|
84
|
+
|
85
|
+
it "returns true" do
|
86
|
+
stub_get("https://api.github.com/orgs/github/members/pengwynn").
|
87
|
+
to_return(:status => 204)
|
88
|
+
is_hubbernaut = @client.organization_member?('github', 'pengwynn')
|
89
|
+
expect(is_hubbernaut).to be_true
|
90
|
+
end
|
91
|
+
|
92
|
+
end
|
93
|
+
|
94
|
+
context "user is not actually a member of the organization" do
|
95
|
+
|
96
|
+
it "returns false" do
|
97
|
+
stub_get("https://api.github.com/orgs/github/members/joeyw").
|
98
|
+
to_return(:status => 404)
|
99
|
+
is_hubbernaut = @client.organization_member?('github', 'joeyw')
|
100
|
+
expect(is_hubbernaut).to be_false
|
101
|
+
end
|
102
|
+
|
103
|
+
end
|
104
|
+
|
105
|
+
end
|
106
|
+
|
107
|
+
describe ".organization_public_member?" do
|
108
|
+
|
109
|
+
context "user is actually a public member of the organization" do
|
110
|
+
|
111
|
+
it "returns true" do
|
112
|
+
stub_get("https://api.github.com/orgs/github/public_members/pengwynn").
|
113
|
+
to_return(:status => 204)
|
114
|
+
is_hubbernaut = @client.organization_public_member?('github', 'pengwynn')
|
115
|
+
expect(is_hubbernaut).to be_true
|
116
|
+
end
|
117
|
+
|
118
|
+
end
|
119
|
+
|
120
|
+
context "user is not actually a public member of the organization" do
|
121
|
+
|
122
|
+
it "returns false" do
|
123
|
+
stub_get("https://api.github.com/orgs/github/public_members/joeyw").
|
124
|
+
to_return(:status => 404)
|
125
|
+
is_hubbernaut = @client.organization_public_member?('github', 'joeyw')
|
126
|
+
expect(is_hubbernaut).to be_false
|
127
|
+
end
|
128
|
+
|
129
|
+
end
|
130
|
+
|
131
|
+
end
|
132
|
+
|
81
133
|
describe ".organization_teams" do
|
82
134
|
|
83
135
|
it "returns all teams for an organization" do
|
84
136
|
stub_get("https://api.github.com/orgs/codeforamerica/teams").
|
85
|
-
to_return(
|
137
|
+
to_return(json_response("teams.json"))
|
86
138
|
teams = @client.organization_teams("codeforamerica")
|
87
139
|
expect(teams.first.name).to eq("Fellows")
|
88
140
|
end
|
@@ -94,7 +146,7 @@ describe Octokit::Client::Organizations do
|
|
94
146
|
it "creates a team" do
|
95
147
|
stub_post("https://api.github.com/orgs/codeforamerica/teams").
|
96
148
|
with(:name => "Fellows").
|
97
|
-
to_return(
|
149
|
+
to_return(json_response("team.json"))
|
98
150
|
team = @client.create_team("codeforamerica", {:name => "Fellows"})
|
99
151
|
expect(team.name).to eq("Fellows")
|
100
152
|
end
|
@@ -105,7 +157,7 @@ describe Octokit::Client::Organizations do
|
|
105
157
|
|
106
158
|
it "returns a team" do
|
107
159
|
stub_get("https://api.github.com/teams/32598").
|
108
|
-
to_return(
|
160
|
+
to_return(json_response("team.json"))
|
109
161
|
team = @client.team(32598)
|
110
162
|
expect(team.name).to eq("Fellows")
|
111
163
|
end
|
@@ -117,7 +169,7 @@ describe Octokit::Client::Organizations do
|
|
117
169
|
it "updates a team" do
|
118
170
|
stub_patch("https://api.github.com/teams/32598").
|
119
171
|
with(:name => "Fellows").
|
120
|
-
to_return(
|
172
|
+
to_return(json_response("team.json"))
|
121
173
|
team = @client.update_team(32598, :name => "Fellows")
|
122
174
|
expect(team.name).to eq("Fellows")
|
123
175
|
end
|
@@ -130,7 +182,7 @@ describe Octokit::Client::Organizations do
|
|
130
182
|
stub_delete("https://api.github.com/teams/32598").
|
131
183
|
to_return(:status => 204)
|
132
184
|
result = @client.delete_team(32598)
|
133
|
-
expect(result
|
185
|
+
expect(result).to be_true
|
134
186
|
end
|
135
187
|
|
136
188
|
end
|
@@ -140,7 +192,7 @@ describe Octokit::Client::Organizations do
|
|
140
192
|
|
141
193
|
it "returns team members" do
|
142
194
|
stub_get("https://api.github.com/teams/33239/members").
|
143
|
-
to_return(
|
195
|
+
to_return(json_response("organization_team_members.json"))
|
144
196
|
users = @client.team_members(33239)
|
145
197
|
expect(users.first.login).to eq("ctshryock")
|
146
198
|
end
|
@@ -183,7 +235,7 @@ describe Octokit::Client::Organizations do
|
|
183
235
|
|
184
236
|
it "returns team repositories" do
|
185
237
|
stub_get("https://api.github.com/teams/33239/repos").
|
186
|
-
to_return(
|
238
|
+
to_return(json_response("organization_team_repos.json"))
|
187
239
|
repositories = @client.team_repositories(33239)
|
188
240
|
expect(repositories.first.name).to eq("GitTalk")
|
189
241
|
expect(repositories.first.owner.id).to eq(570695)
|
@@ -14,12 +14,12 @@ describe Octokit::Client::PubSubHubbub::ServiceHooks do
|
|
14
14
|
}
|
15
15
|
}
|
16
16
|
it "subscribes to pull events on specified topic" do
|
17
|
-
stub_post("/hub
|
17
|
+
stub_post("/hub").
|
18
18
|
with(subscribe_request_body).
|
19
19
|
to_return(:body => nil)
|
20
20
|
|
21
21
|
expect(client.subscribe_service_hook("joshk/completeness-fu", "Travis", { :token => 'travistoken' })).to eq(true)
|
22
|
-
assert_requested :post, "https://api.github.com/hub
|
22
|
+
assert_requested :post, "https://api.github.com/hub", :body => subscribe_request_body, :times => 1
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
@@ -33,12 +33,12 @@ describe Octokit::Client::PubSubHubbub::ServiceHooks do
|
|
33
33
|
}
|
34
34
|
|
35
35
|
it "unsubscribes to stop receiving events on specified topic" do
|
36
|
-
stub_post("/hub
|
36
|
+
stub_post("/hub").
|
37
37
|
with(unsubscribe_request_body).
|
38
38
|
to_return(:body => nil)
|
39
39
|
|
40
40
|
expect(client.unsubscribe_service_hook("joshk/completeness-fu", "Travis")).to eq(true)
|
41
|
-
assert_requested :post, "https://api.github.com/hub
|
41
|
+
assert_requested :post, "https://api.github.com/hub", :body => unsubscribe_request_body, :times => 1
|
42
42
|
end
|
43
43
|
end
|
44
44
|
end
|