octokit 1.18.0 → 1.19.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (173) hide show
  1. data/.document +1 -1
  2. data/.rspec +1 -0
  3. data/CHANGELOG.md +25 -0
  4. data/{LICENSE → LICENSE.md} +0 -0
  5. data/README.md +25 -8
  6. data/lib/faraday/response/raise_octokit_error.rb +4 -1
  7. data/lib/octokit/client.rb +6 -0
  8. data/lib/octokit/client/authorizations.rb +20 -7
  9. data/lib/octokit/client/commits.rb +120 -13
  10. data/lib/octokit/client/contents.rb +3 -4
  11. data/lib/octokit/client/downloads.rb +4 -3
  12. data/lib/octokit/client/emojis.rb +1 -1
  13. data/lib/octokit/client/events.rb +4 -4
  14. data/lib/octokit/client/gists.rb +33 -31
  15. data/lib/octokit/client/issues.rb +15 -15
  16. data/lib/octokit/client/labels.rb +13 -13
  17. data/lib/octokit/client/markdown.rb +2 -1
  18. data/lib/octokit/client/milestones.rb +6 -6
  19. data/lib/octokit/client/notifications.rb +222 -0
  20. data/lib/octokit/client/objects.rb +4 -4
  21. data/lib/octokit/client/organizations.rb +65 -20
  22. data/lib/octokit/client/pub_sub_hubbub.rb +2 -2
  23. data/lib/octokit/client/pulls.rb +91 -3
  24. data/lib/octokit/client/rate_limit.rb +20 -0
  25. data/lib/octokit/client/refs.rb +4 -4
  26. data/lib/octokit/client/repositories.rb +106 -37
  27. data/lib/octokit/client/say.rb +14 -0
  28. data/lib/octokit/client/statuses.rb +2 -2
  29. data/lib/octokit/client/users.rb +92 -24
  30. data/lib/octokit/connection.rb +21 -21
  31. data/lib/octokit/request.rb +47 -36
  32. data/lib/octokit/version.rb +1 -1
  33. data/octokit.gemspec +25 -25
  34. data/spec/fixtures/{v3/authorization.json → authorization.json} +0 -0
  35. data/spec/fixtures/{v3/authorizations.json → authorizations.json} +0 -0
  36. data/spec/fixtures/{v3/blob.json → blob.json} +0 -0
  37. data/spec/fixtures/{v3/blob_create.json → blob_create.json} +0 -0
  38. data/spec/fixtures/{v3/branches.json → branches.json} +0 -0
  39. data/spec/fixtures/{v3/collaborators.json → collaborators.json} +0 -0
  40. data/spec/fixtures/{v3/comment.json → comment.json} +0 -0
  41. data/spec/fixtures/{v3/comments.json → comments.json} +0 -0
  42. data/spec/fixtures/{v3/commit.json → commit.json} +0 -0
  43. data/spec/fixtures/{v3/commit_comment.json → commit_comment.json} +0 -0
  44. data/spec/fixtures/{v3/commit_comment_create.json → commit_comment_create.json} +0 -0
  45. data/spec/fixtures/{v3/commit_comment_update.json → commit_comment_update.json} +0 -0
  46. data/spec/fixtures/{v3/commit_comments.json → commit_comments.json} +0 -0
  47. data/spec/fixtures/{v3/commit_create.json → commit_create.json} +0 -0
  48. data/spec/fixtures/{v3/commits.json → commits.json} +0 -0
  49. data/spec/fixtures/{v3/compare.json → compare.json} +0 -0
  50. data/spec/fixtures/{v3/contents.json → contents.json} +0 -0
  51. data/spec/fixtures/{v3/contributors.json → contributors.json} +0 -0
  52. data/spec/fixtures/{v3/download.json → download.json} +0 -0
  53. data/spec/fixtures/{v3/download_create.json → download_create.json} +0 -0
  54. data/spec/fixtures/{v3/downloads.json → downloads.json} +0 -0
  55. data/spec/fixtures/{v3/emails.json → emails.json} +0 -0
  56. data/spec/fixtures/{v3/emojis.json → emojis.json} +0 -0
  57. data/spec/fixtures/{v3/followers.json → followers.json} +0 -0
  58. data/spec/fixtures/{v3/following.json → following.json} +0 -0
  59. data/spec/fixtures/{v3/forks.json → forks.json} +0 -0
  60. data/spec/fixtures/{v3/gist.json → gist.json} +0 -0
  61. data/spec/fixtures/{v3/gist_comment.json → gist_comment.json} +0 -0
  62. data/spec/fixtures/{v3/gist_comment_create.json → gist_comment_create.json} +0 -0
  63. data/spec/fixtures/{v3/gist_comment_update.json → gist_comment_update.json} +0 -0
  64. data/spec/fixtures/{v3/gist_comments.json → gist_comments.json} +0 -0
  65. data/spec/fixtures/{v3/gists.json → gists.json} +0 -0
  66. data/spec/fixtures/{v3/hook.json → hook.json} +0 -0
  67. data/spec/fixtures/{v3/hooks.json → hooks.json} +0 -0
  68. data/spec/fixtures/{v3/issue.json → issue.json} +0 -0
  69. data/spec/fixtures/{v3/issue_closed.json → issue_closed.json} +0 -0
  70. data/spec/fixtures/{v3/issue_event.json → issue_event.json} +0 -0
  71. data/spec/fixtures/{v3/issue_events.json → issue_events.json} +0 -0
  72. data/spec/fixtures/issue_full.json +38 -0
  73. data/spec/fixtures/{v3/issues.json → issues.json} +0 -0
  74. data/spec/fixtures/{v3/label.json → label.json} +0 -0
  75. data/spec/fixtures/{v3/labels.json → labels.json} +0 -0
  76. data/spec/fixtures/{v3/languages.json → languages.json} +0 -0
  77. data/spec/fixtures/{v3/list_commit_comments.json → list_commit_comments.json} +0 -0
  78. data/spec/fixtures/{v3/markdown_gfm → markdown_gfm} +0 -0
  79. data/spec/fixtures/{v3/merge.json → merge.json} +0 -0
  80. data/spec/fixtures/{v3/milestone.json → milestone.json} +0 -0
  81. data/spec/fixtures/{v3/milestones.json → milestones.json} +0 -0
  82. data/spec/fixtures/{v3/not_found.json → not_found.json} +0 -0
  83. data/spec/fixtures/notification_thread.json +32 -0
  84. data/spec/fixtures/notifications.json +32 -0
  85. data/spec/fixtures/{v3/organization-repositories.json → organization-repositories.json} +0 -0
  86. data/spec/fixtures/{v3/organization-repository.json → organization-repository.json} +0 -0
  87. data/spec/fixtures/{v3/organization.json → organization.json} +0 -0
  88. data/spec/fixtures/{v3/organization_members.json → organization_members.json} +0 -0
  89. data/spec/fixtures/{v3/organization_team_members.json → organization_team_members.json} +0 -0
  90. data/spec/fixtures/{v3/organization_team_repos.json → organization_team_repos.json} +0 -0
  91. data/spec/fixtures/{v3/organizations.json → organizations.json} +0 -0
  92. data/spec/fixtures/{v3/public_events.json → public_events.json} +0 -0
  93. data/spec/fixtures/{v3/public_gists.json → public_gists.json} +0 -0
  94. data/spec/fixtures/{v3/public_key.json → public_key.json} +0 -0
  95. data/spec/fixtures/public_key_update.json +5 -0
  96. data/spec/fixtures/{v3/public_keys.json → public_keys.json} +0 -0
  97. data/spec/fixtures/{v3/pull_created.json → pull_created.json} +0 -0
  98. data/spec/fixtures/{v3/pull_request.json → pull_request.json} +0 -0
  99. data/spec/fixtures/pull_request_comment.json +35 -0
  100. data/spec/fixtures/pull_request_comment_create.json +35 -0
  101. data/spec/fixtures/pull_request_comment_reply.json +35 -0
  102. data/spec/fixtures/pull_request_comment_update.json +35 -0
  103. data/spec/fixtures/{v3/pull_request_comments.json → pull_request_comments.json} +0 -0
  104. data/spec/fixtures/{v3/pull_request_commits.json → pull_request_commits.json} +0 -0
  105. data/spec/fixtures/{v3/pull_request_files.json → pull_request_files.json} +0 -0
  106. data/spec/fixtures/{v3/pull_request_merged.json → pull_request_merged.json} +0 -0
  107. data/spec/fixtures/{v3/pull_requests.json → pull_requests.json} +0 -0
  108. data/spec/fixtures/{v3/pull_update.json → pull_update.json} +0 -0
  109. data/spec/fixtures/{v3/readme.json → readme.json} +0 -0
  110. data/spec/fixtures/{v3/ref.json → ref.json} +0 -0
  111. data/spec/fixtures/{v3/ref_create.json → ref_create.json} +0 -0
  112. data/spec/fixtures/{v3/ref_update.json → ref_update.json} +0 -0
  113. data/spec/fixtures/{v3/refs.json → refs.json} +0 -0
  114. data/spec/fixtures/{v3/refs_tags.json → refs_tags.json} +0 -0
  115. data/spec/fixtures/{v3/repo_assignees.json → repo_assignees.json} +0 -0
  116. data/spec/fixtures/{v3/repo_events.json → repo_events.json} +0 -0
  117. data/spec/fixtures/{v3/repo_issues_events.json → repo_issues_events.json} +0 -0
  118. data/spec/fixtures/{v3/repositories.json → repositories.json} +0 -0
  119. data/spec/fixtures/{v3/repository.json → repository.json} +0 -0
  120. data/spec/fixtures/repository_notifications.json +32 -0
  121. data/spec/fixtures/say.txt +22 -0
  122. data/spec/fixtures/say_custom.txt +22 -0
  123. data/spec/fixtures/{v3/stargazers.json → stargazers.json} +0 -0
  124. data/spec/fixtures/{v3/starred.json → starred.json} +0 -0
  125. data/spec/fixtures/{v3/starred_gists.json → starred_gists.json} +0 -0
  126. data/spec/fixtures/{v3/status.json → status.json} +0 -0
  127. data/spec/fixtures/{v3/statuses.json → statuses.json} +0 -0
  128. data/spec/fixtures/subscribers.json +9 -0
  129. data/spec/fixtures/subscription.json +8 -0
  130. data/spec/fixtures/subscription_update.json +8 -0
  131. data/spec/fixtures/subscriptions.json +39 -0
  132. data/spec/fixtures/{v3/tag.json → tag.json} +0 -0
  133. data/spec/fixtures/{v3/tag_create.json → tag_create.json} +0 -0
  134. data/spec/fixtures/{v3/tags.json → tags.json} +0 -0
  135. data/spec/fixtures/{v3/team.json → team.json} +0 -0
  136. data/spec/fixtures/{v3/teams.json → teams.json} +0 -0
  137. data/spec/fixtures/thread_subscription.json +8 -0
  138. data/spec/fixtures/thread_subscription_update.json +8 -0
  139. data/spec/fixtures/{v3/tree.json → tree.json} +0 -0
  140. data/spec/fixtures/{v3/tree_create.json → tree_create.json} +0 -0
  141. data/spec/fixtures/{v3/user.json → user.json} +0 -0
  142. data/spec/fixtures/{v3/user_events.json → user_events.json} +0 -0
  143. data/spec/fixtures/validation_failed.json +11 -0
  144. data/spec/fixtures/{v3/watched.json → watched.json} +0 -0
  145. data/spec/fixtures/{v3/watchers.json → watchers.json} +0 -0
  146. data/spec/helper.rb +13 -2
  147. data/spec/octokit/client/authorizations_spec.rb +44 -7
  148. data/spec/octokit/client/commits_spec.rb +136 -11
  149. data/spec/octokit/client/contents_spec.rb +6 -3
  150. data/spec/octokit/client/downloads_spec.rb +5 -6
  151. data/spec/octokit/client/emojis_spec.rb +1 -1
  152. data/spec/octokit/client/events_spec.rb +5 -5
  153. data/spec/octokit/client/gists_spec.rb +20 -20
  154. data/spec/octokit/client/issue_events_spec.rb +2 -2
  155. data/spec/octokit/client/issues_spec.rb +25 -14
  156. data/spec/octokit/client/labels_spec.rb +18 -22
  157. data/spec/octokit/client/markdown_spec.rb +1 -1
  158. data/spec/octokit/client/milestones_spec.rb +8 -8
  159. data/spec/octokit/client/notifications_spec.rb +141 -0
  160. data/spec/octokit/client/objects_spec.rb +6 -6
  161. data/spec/octokit/client/organizations_spec.rb +65 -13
  162. data/spec/octokit/client/pub_sub_hubbub/service_hooks_spec.rb +4 -4
  163. data/spec/octokit/client/pub_sub_hubbub_spec.rb +3 -3
  164. data/spec/octokit/client/pulls_spec.rb +81 -10
  165. data/spec/octokit/client/refs_spec.rb +7 -7
  166. data/spec/octokit/client/repositories_spec.rb +86 -34
  167. data/spec/octokit/client/say_spec.rb +37 -0
  168. data/spec/octokit/client/statuses_spec.rb +2 -2
  169. data/spec/octokit/client/users_spec.rb +65 -16
  170. data/spec/octokit/client_spec.rb +37 -11
  171. data/spec/{repository_spec.rb → octokit/repository_spec.rb} +0 -0
  172. data/spec/octokit_spec.rb +1 -1
  173. metadata +240 -196
@@ -11,7 +11,7 @@ describe Octokit::Client::Contents do
11
11
 
12
12
  it "returns the default readme" do
13
13
  stub_get("/repos/pengwynn/octokit/readme").
14
- to_return(:body => fixture("v3/readme.json"))
14
+ to_return(json_response("readme.json"))
15
15
  readme = @client.readme('pengwynn/octokit')
16
16
  expect(readme.encoding).to eq("base64")
17
17
  expect(readme.type).to eq("file")
@@ -23,7 +23,7 @@ describe Octokit::Client::Contents do
23
23
 
24
24
  it "returns the contents of a file" do
25
25
  stub_get("/repos/pengwynn/octokit/contents/lib/octokit.rb").
26
- to_return(:body => fixture("v3/contents.json"))
26
+ to_return(json_response("contents.json"))
27
27
  contents = @client.contents('pengwynn/octokit', :path => "lib/octokit.rb")
28
28
  expect(contents.path).to eq("lib/octokit.rb")
29
29
  expect(contents.name).to eq("lib/octokit.rb")
@@ -36,9 +36,12 @@ describe Octokit::Client::Contents do
36
36
  describe ".archive_link" do
37
37
 
38
38
  it "returns the headers of the request" do
39
- stub_get("/repos/pengwynn/octokit/tarball/master").
39
+ stub_head("/repos/pengwynn/octokit/tarball/master").
40
40
  to_return(:status => 302, :body => '', :headers =>
41
41
  { 'location' => "https://nodeload.github.com/repos/pengwynn/octokit/tarball/"})
42
+ stub_head("https://nodeload.github.com/repos/pengwynn/octokit/tarball/").
43
+ to_return(:status => 200)
44
+
42
45
  archive_link = @client.archive_link('pengwynn/octokit', :ref => "master")
43
46
  expect(archive_link).to eq("https://nodeload.github.com/repos/pengwynn/octokit/tarball/")
44
47
  end
@@ -11,7 +11,7 @@ describe Octokit::Client::Downloads do
11
11
 
12
12
  it "lists available downloads" do
13
13
  stub_get("/repos/github/hubot/downloads").
14
- to_return(:body => fixture("v3/downloads.json"))
14
+ to_return(json_response("downloads.json"))
15
15
  downloads = @client.downloads("github/hubot")
16
16
  expect(downloads.first.description).to eq("Robawt")
17
17
  end
@@ -22,7 +22,7 @@ describe Octokit::Client::Downloads do
22
22
 
23
23
  it "gets a single download" do
24
24
  stub_get("/repos/github/hubot/downloads/165347").
25
- to_return(:body => fixture("v3/download.json"))
25
+ to_return(json_response("download.json"))
26
26
  download = @client.download("github/hubot", 165347)
27
27
  expect(download.id).to eq(165347)
28
28
  expect(download.name).to eq('hubot-2.1.0.tar.gz')
@@ -36,7 +36,7 @@ describe Octokit::Client::Downloads do
36
36
  with(:body => {:name => "download_create.json", :size => 690,
37
37
  :description => "Description of your download",
38
38
  :content_type => "text/plain" }).
39
- to_return(:body => fixture("v3/download_create.json"))
39
+ to_return(json_response("download_create.json"))
40
40
  end
41
41
  it "creates a download resource" do
42
42
  resource = @client.send(:create_download_resource, "octocat/Hello-World", "download_create.json", 690, {:description => "Description of your download", :content_type => "text/plain"})
@@ -46,7 +46,7 @@ describe Octokit::Client::Downloads do
46
46
  it "posts to an S3 url" do
47
47
  stub_post("https://github.s3.amazonaws.com/").
48
48
  to_return(:status => 201)
49
- file_path = File.expand_path 'spec/fixtures/v3/download_create.json'
49
+ file_path = File.expand_path 'spec/fixtures/download_create.json'
50
50
  expect(@client.create_download("octocat/Hello-World", file_path, {:description => "Description of your download", :content_type => "text/plain"})).to eq(true)
51
51
  end
52
52
  end
@@ -55,9 +55,8 @@ describe Octokit::Client::Downloads do
55
55
 
56
56
  it "deletes a download" do
57
57
  stub_request(:delete, "https://api.github.com/repos/octocat/Hellow-World/downloads/165347").
58
- with(:headers => {'Accept'=>'*/*'}).
59
58
  to_return(:status => 204, :body => "", :headers => {})
60
- expect(@client.delete_download('octocat/Hellow-World', 165347).status).to eq(204)
59
+ expect(@client.delete_download('octocat/Hellow-World', 165347)).to be_true
61
60
  end
62
61
  end
63
62
 
@@ -9,7 +9,7 @@ describe Octokit::Client::Emojis do
9
9
  describe ".emojis" do
10
10
  it "returns all github emojis" do
11
11
  stub_get("/emojis").
12
- to_return(:body => fixture("v3/emojis.json"))
12
+ to_return(json_response("emojis.json"))
13
13
  emojis = @client.emojis
14
14
  expect(emojis[:metal]).to eq('https://a248.e.akamai.net/assets.github.com/images/icons/emoji/metal.png?v5')
15
15
  end
@@ -9,7 +9,7 @@ describe Octokit::Client::Events do
9
9
  describe ".public_events" do
10
10
  it "returns all public events" do
11
11
  stub_get("/events").
12
- to_return(:body => fixture("v3/public_events.json"))
12
+ to_return json_response("public_events.json")
13
13
  public_events = @client.public_events
14
14
  expect(public_events.first.id).to eq('1513284759')
15
15
  end
@@ -18,7 +18,7 @@ describe Octokit::Client::Events do
18
18
  describe ".user_events" do
19
19
  it "returns all user events" do
20
20
  stub_get("/users/sferik/events").
21
- to_return(:body => fixture("v3/user_events.json"))
21
+ to_return json_response("user_events.json")
22
22
  user_events = @client.user_events('sferik')
23
23
  expect(user_events.first.id).to eq('1525888969')
24
24
  end
@@ -27,7 +27,7 @@ describe Octokit::Client::Events do
27
27
  describe ".received_events" do
28
28
  it "returns all user received events" do
29
29
  stub_get("/users/sferik/received_events").
30
- to_return(:body => fixture("v3/user_events.json"))
30
+ to_return json_response("user_events.json")
31
31
  received_events = @client.received_events('sferik')
32
32
  expect(received_events.first.type).to eq('PushEvent')
33
33
  end
@@ -36,10 +36,10 @@ describe Octokit::Client::Events do
36
36
  describe ".repository_events" do
37
37
  it "returns events for a repository" do
38
38
  stub_get("/repos/sferik/rails_admin/events").
39
- to_return(:body => fixture("v3/repo_events.json"))
39
+ to_return json_response("repo_events.json")
40
40
  repo_events = @client.repository_events("sferik/rails_admin")
41
41
  expect(repo_events.first.type).to eq("IssuesEvent")
42
42
  end
43
-
43
+
44
44
  end
45
45
  end
@@ -10,7 +10,7 @@ describe Octokit::Client::Gists do
10
10
 
11
11
  describe ".public_gists" do
12
12
  it "returns public gists" do
13
- stub_get("/gists/public").to_return(:body => fixture("v3/public_gists.json"))
13
+ stub_get("/gists/public").to_return(json_response("public_gists.json"))
14
14
  gists = @client.public_gists
15
15
  expect(gists).not_to be_empty
16
16
  end
@@ -20,7 +20,7 @@ describe Octokit::Client::Gists do
20
20
  context "with username passed" do
21
21
  it "returns a list of gists" do
22
22
  stub_get("/users/#{@username}/gists").
23
- to_return(:body => fixture("v3/gists.json"))
23
+ to_return(json_response("gists.json"))
24
24
  gists = @client.gists(@username)
25
25
  expect(gists.first.user.login).to eq(@username)
26
26
  end
@@ -28,7 +28,7 @@ describe Octokit::Client::Gists do
28
28
 
29
29
  context "without a username passed" do
30
30
  it "returns a list of gists" do
31
- stub_get("/gists").to_return(:body => fixture("v3/gists.json"))
31
+ stub_get("/gists").to_return(json_response("gists.json"))
32
32
  gists = @client.gists
33
33
  expect(gists.first.user.login).to eq(@username)
34
34
  end
@@ -37,7 +37,7 @@ describe Octokit::Client::Gists do
37
37
 
38
38
  describe ".starred_gists" do
39
39
  it "returns the user's starred gists" do
40
- stub_get("/gists/starred").to_return(:body => fixture("v3/starred_gists.json"))
40
+ stub_get("/gists/starred").to_return(json_response("starred_gists.json"))
41
41
  gists = @client.starred_gists
42
42
  expect(gists).not_to be_empty
43
43
  end
@@ -45,7 +45,7 @@ describe Octokit::Client::Gists do
45
45
 
46
46
  describe ".gist" do
47
47
  it "returns the gist by ID" do
48
- stub_get("/gists/1").to_return(:body => fixture("v3/gist.json"))
48
+ stub_get("/gists/1").to_return(json_response("gist.json"))
49
49
  gist = @client.gist(1)
50
50
  expect(gist.user.login).to eq(@username)
51
51
  end
@@ -53,7 +53,7 @@ describe Octokit::Client::Gists do
53
53
 
54
54
  describe ".create_gist" do
55
55
  it "creates a new gist" do
56
- gist_content = JSON.parse(fixture("v3/gist.json").read)
56
+ gist_content = JSON.parse(fixture("gist.json").read)
57
57
  new_gist = {
58
58
  :description => gist_content['description'],
59
59
  :public => gist_content['public'],
@@ -61,7 +61,7 @@ describe Octokit::Client::Gists do
61
61
  }
62
62
 
63
63
  stub_post("/gists").with(new_gist).
64
- to_return(:body => fixture("v3/gist.json"))
64
+ to_return(json_response("gist.json"))
65
65
 
66
66
  gist = @client.create_gist(new_gist)
67
67
  expect(gist).to eq(gist_content)
@@ -70,7 +70,7 @@ describe Octokit::Client::Gists do
70
70
 
71
71
  describe ".edit_gist" do
72
72
  it "edit an existing gist" do
73
- gist_content = JSON.parse(fixture("v3/gist.json").read)
73
+ gist_content = JSON.parse(fixture("gist.json").read)
74
74
  gist_id = gist_content['id']
75
75
  updated_gist = gist_content.merge('description' => 'updated')
76
76
 
@@ -115,7 +115,7 @@ describe Octokit::Client::Gists do
115
115
  describe ".fork_gist" do
116
116
  it "forks an existing gist" do
117
117
  stub_post("/gists/12345/fork").
118
- to_return(:body => fixture("v3/gist.json"))
118
+ to_return(json_response("gist.json"))
119
119
 
120
120
  gist = @client.fork_gist(12345)
121
121
  expect(gist.user.login).to eq(@username)
@@ -133,7 +133,7 @@ describe Octokit::Client::Gists do
133
133
  describe ".gist_comments" do
134
134
  it "returns the list of gist comments" do
135
135
  stub_get("/gists/12345/comments").
136
- to_return(:body => fixture("v3/gist_comments.json"))
136
+ to_return(json_response("gist_comments.json"))
137
137
  comments = @client.gist_comments(12345)
138
138
  expect(comments.first.id).to eq(451398)
139
139
  end
@@ -141,9 +141,9 @@ describe Octokit::Client::Gists do
141
141
 
142
142
  describe ".gist_comment" do
143
143
  it "returns a gist comment" do
144
- stub_get("/gists/comments/12345").
145
- to_return(:body => fixture("v3/gist_comment.json"))
146
- comment = @client.gist_comment(12345)
144
+ stub_get("/gists/4bcad24/comments/12345").
145
+ to_return(json_response("gist_comment.json"))
146
+ comment = @client.gist_comment("4bcad24", 12345)
147
147
  expect(comment.id).to eq(451398)
148
148
  end
149
149
  end
@@ -151,8 +151,8 @@ describe Octokit::Client::Gists do
151
151
  describe ".create_gist_comment" do
152
152
  it "creates a gist comment" do
153
153
  stub_post("/gists/12345/comments").
154
- to_return(:body => fixture("v3/gist_comment_create.json"))
155
- comment = @client.create_gist_comment(12345, "This is very helpful.")
154
+ to_return(json_response("gist_comment_create.json"))
155
+ comment = @client.create_gist_comment('12345', "This is very helpful.")
156
156
  expect(comment.id).to eq(586399)
157
157
  expect(comment.body).to eq("This is very helpful.")
158
158
  end
@@ -160,17 +160,17 @@ describe Octokit::Client::Gists do
160
160
 
161
161
  describe ".update_gist_comment" do
162
162
  it "updates a gist comment" do
163
- stub_patch("/gists/comments/12345").
164
- to_return(:body => fixture("v3/gist_comment_update.json"))
165
- comment = @client.update_gist_comment(12345, ":heart:")
163
+ stub_patch("/gists/4bcad24/comments/12345").
164
+ to_return(json_response("gist_comment_update.json"))
165
+ comment = @client.update_gist_comment("4bcad24", 12345, ":heart:")
166
166
  expect(comment.body).to eq(":heart:")
167
167
  end
168
168
  end
169
169
 
170
170
  describe ".delete_gist_comment" do
171
171
  it "deletes a gist comment" do
172
- stub_delete("/gists/comments/12345").to_return(:status => 204)
173
- result = @client.delete_gist_comment(12345)
172
+ stub_delete("/gists/4bcad24/comments/12345").to_return(:status => 204)
173
+ result = @client.delete_gist_comment("4bcad24", 12345)
174
174
  expect(result).to be_true
175
175
  end
176
176
  end
@@ -11,7 +11,7 @@ describe Octokit::Client::Issues do
11
11
 
12
12
  it "lists events for an issue" do
13
13
  stub_get("/repos/pengwynn/octokit/issues/38/events").
14
- to_return(:body => fixture("v3/issue_events.json"))
14
+ to_return(json_response("issue_events.json"))
15
15
  events = @client.issue_events("pengwynn/octokit", 38)
16
16
  expect(events.first.event).to eq("mentioned")
17
17
  expect(events.last.actor.login).to eq("ctshryock")
@@ -19,7 +19,7 @@ describe Octokit::Client::Issues do
19
19
 
20
20
  it "gets a single event" do
21
21
  stub_get("/repos/pengwynn/octokit/issues/events/3094334").
22
- to_return(:body => fixture("v3/issue_event.json"))
22
+ to_return(json_response("issue_event.json"))
23
23
  events = @client.issue_event("pengwynn/octokit", 3094334)
24
24
  expect(events.actor.login).to eq("sferik")
25
25
  expect(events.event).to eq("closed")
@@ -11,7 +11,7 @@ describe Octokit::Client::Issues do
11
11
 
12
12
  it "returns matching issues" do
13
13
  stub_get("https://api.github.com/legacy/issues/search/sferik/rails_admin/open/activerecord").
14
- to_return(:body => fixture("legacy/issues.json"))
14
+ to_return(json_response("legacy/issues.json"))
15
15
  issues = @client.search_issues("sferik/rails_admin", "activerecord")
16
16
  expect(issues.first.number).to eq(105)
17
17
  end
@@ -22,14 +22,14 @@ describe Octokit::Client::Issues do
22
22
 
23
23
  it "returns issues for a repository" do
24
24
  stub_get("/repos/sferik/rails_admin/issues").
25
- to_return(:body => fixture("v3/issues.json"))
25
+ to_return(json_response("issues.json"))
26
26
  issues = @client.issues("sferik/rails_admin")
27
27
  expect(issues.first.number).to eq(388)
28
28
  end
29
29
 
30
30
  it "returns issues for the authenticated user" do
31
31
  stub_get("/issues").
32
- to_return(:body => fixture("v3/issues.json"))
32
+ to_return(json_response("issues.json"))
33
33
  issues = @client.issues
34
34
  expect(issues.first.number).to eq(388)
35
35
  end
@@ -42,7 +42,7 @@ describe Octokit::Client::Issues do
42
42
  stub_post("/repos/ctshryock/octokit/issues").
43
43
  with(:body => {"title" => "Migrate issues to v3", "body" => "Move all Issues calls to v3 of the API"},
44
44
  :headers => {'Content-Type'=>'application/json'}).
45
- to_return(:body => fixture("v3/issue.json"))
45
+ to_return(json_response("issue.json"))
46
46
  issue = @client.create_issue("ctshryock/octokit", "Migrate issues to v3", "Move all Issues calls to v3 of the API")
47
47
  expect(issue.number).to eq(12)
48
48
  end
@@ -53,11 +53,22 @@ describe Octokit::Client::Issues do
53
53
 
54
54
  it "returns an issue" do
55
55
  stub_get("/repos/ctshryock/octokit/issues/12").
56
- to_return(:body => fixture("v3/issue.json"))
56
+ to_return(json_response("issue.json"))
57
57
  issue = @client.issue("ctshryock/octokit", 12)
58
58
  expect(issue.number).to eq(12)
59
59
  end
60
60
 
61
+ context "with media_type param full" do
62
+
63
+ it "returns an issue" do
64
+ stub_get("/repos/pengwynn/octokit/issues/1").
65
+ to_return(json_response('issue_full.json'))
66
+ issue = @client.issue("pengwynn/octokit", 1, :accept => 'application/vnd.github.full+json')
67
+ expect(issue.body_html).to include('<p>Create, Edit, Delete missing')
68
+ expect(issue.body_text).to include('Create, Edit, Delete missing')
69
+ end
70
+ end
71
+
61
72
  end
62
73
 
63
74
  describe ".close_issue" do
@@ -66,7 +77,7 @@ describe Octokit::Client::Issues do
66
77
  stub_post("/repos/ctshryock/octokit/issues/12").
67
78
  with(:body => {"state" => "closed"},
68
79
  :headers => {'Content-Type'=>'application/json'}).
69
- to_return(:body => fixture("v3/issue_closed.json"))
80
+ to_return(json_response("issue_closed.json"))
70
81
  issue = @client.close_issue("ctshryock/octokit", 12)
71
82
  expect(issue.number).to eq(12)
72
83
  expect(issue).to include :closed_at
@@ -81,7 +92,7 @@ describe Octokit::Client::Issues do
81
92
  stub_post("/repos/ctshryock/octokit/issues/12").
82
93
  with(:body => {"state" => "open"},
83
94
  :headers => {'Content-Type'=>'application/json'}).
84
- to_return(:body => fixture("v3/issue.json"))
95
+ to_return(json_response("issue.json"))
85
96
  issue = @client.reopen_issue("ctshryock/octokit", 12)
86
97
  expect(issue.number).to eq(12)
87
98
  expect(issue.state).to eq("open")
@@ -95,7 +106,7 @@ describe Octokit::Client::Issues do
95
106
  stub_post("/repos/ctshryock/octokit/issues/12").
96
107
  with(:body => {"title" => "Use all the v3 api!", "body" => ""},
97
108
  :headers => {'Content-Type'=>'application/json'}).
98
- to_return(:body => fixture("v3/issue.json"))
109
+ to_return(json_response("issue.json"))
99
110
  issue = @client.update_issue("ctshryock/octokit", 12, "Use all the v3 api!", "")
100
111
  expect(issue.number).to eq(12)
101
112
  end
@@ -106,7 +117,7 @@ describe Octokit::Client::Issues do
106
117
 
107
118
  it "returns comments for an issue" do
108
119
  stub_get("/repos/pengwynn/octokit/issues/25/comments").
109
- to_return(:status => 200, :body => fixture('v3/comments.json'))
120
+ to_return(json_response('comments.json'))
110
121
  comments = @client.issue_comments("pengwynn/octokit", 25)
111
122
  expect(comments.first.user.login).to eq("ctshryock")
112
123
  end
@@ -117,7 +128,7 @@ describe Octokit::Client::Issues do
117
128
 
118
129
  it "returns a single comment for an issue" do
119
130
  stub_get("/repos/pengwynn/octokit/issues/comments/25").
120
- to_return(:status => 200, :body => fixture('v3/comment.json'))
131
+ to_return(json_response('comment.json'))
121
132
  comments = @client.issue_comment("pengwynn/octokit", 25)
122
133
  expect(comments.user.login).to eq("ctshryock")
123
134
  expect(comments.url).to eq("https://api.github.com/repos/pengwynn/octokit/issues/comments/1194690")
@@ -130,7 +141,7 @@ describe Octokit::Client::Issues do
130
141
  it "adds a comment" do
131
142
  stub_post("/repos/pengwynn/octokit/issues/25/comments").
132
143
  with(:body => {"body" => "A test comment"}).
133
- to_return(:status => 201, :body => fixture('v3/comment.json'))
144
+ to_return(json_response('comment.json'))
134
145
  comment = @client.add_comment("pengwynn/octokit", 25, "A test comment")
135
146
  expect(comment.user.login).to eq("ctshryock")
136
147
  end
@@ -142,7 +153,7 @@ describe Octokit::Client::Issues do
142
153
  it "updates an existing comment" do
143
154
  stub_post("/repos/pengwynn/octokit/issues/comments/1194549").
144
155
  with(:body => {"body" => "A test comment update"}).
145
- to_return(:status => 200, :body => fixture('v3/comment.json'))
156
+ to_return(json_response('comment.json'))
146
157
  comment = @client.update_comment("pengwynn/octokit", 1194549, "A test comment update")
147
158
  expect(comment.user.login).to eq("ctshryock")
148
159
  end
@@ -154,8 +165,8 @@ describe Octokit::Client::Issues do
154
165
  it "deletes an existing comment" do
155
166
  stub_delete("/repos/pengwynn/octokit/issues/comments/1194549").
156
167
  to_return(:status => 204)
157
- comment = @client.delete_comment("pengwynn/octokit", 1194549)
158
- expect(comment.status).to eq(204)
168
+ result = @client.delete_comment("pengwynn/octokit", 1194549)
169
+ expect(result).to be_true
159
170
  end
160
171
 
161
172
  end
@@ -11,7 +11,7 @@ describe Octokit::Client::Labels do
11
11
 
12
12
  it "returns labels" do
13
13
  stub_get("/repos/pengwynn/octokit/labels").
14
- to_return(:body => fixture("v3/labels.json"))
14
+ to_return(json_response("labels.json"))
15
15
  labels = @client.labels("pengwynn/octokit")
16
16
  expect(labels.first.name).to eq("V3 Transition")
17
17
  end
@@ -22,7 +22,7 @@ describe Octokit::Client::Labels do
22
22
 
23
23
  it "returns a single labels" do
24
24
  stub_get("/repos/pengwynn/octokit/labels/V3+Addition").
25
- to_return(:status => 200, :body => fixture('v3/label.json'))
25
+ to_return(json_response('label.json'))
26
26
  label = @client.label("pengwynn/octokit", "V3 Addition")
27
27
  expect(label.name).to eq("V3 Addition")
28
28
  end
@@ -33,9 +33,8 @@ describe Octokit::Client::Labels do
33
33
 
34
34
  it "adds a label with a color" do
35
35
  stub_post("/repos/pengwynn/octokit/labels").
36
- with(:body => {"name" => "a significant bug", "color" => "ededed"},
37
- :headers => {'Content-Type'=>'application/json'}).
38
- to_return(:status => 201, :body => fixture('v3/label.json'))
36
+ with(:body => {"name" => "a significant bug", "color" => "ededed"}).
37
+ to_return(json_response('label.json'))
39
38
  labels = @client.add_label("pengwynn/octokit", "a significant bug", 'ededed')
40
39
  expect(labels.color).to eq("ededed")
41
40
  expect(labels.name).to eq("V3 Addition")
@@ -43,9 +42,8 @@ describe Octokit::Client::Labels do
43
42
 
44
43
  it "adds a label with default color" do
45
44
  stub_post("/repos/pengwynn/octokit/labels").
46
- with(:body => {"name" => "another significant bug", "color" => "ffffff"},
47
- :headers => {'Content-Type'=>'application/json'}).
48
- to_return(:status => 201, :body => fixture('v3/label.json'))
45
+ with(:body => {"name" => "another significant bug", "color" => "ffffff"}).
46
+ to_return(json_response('label.json'))
49
47
  labels = @client.add_label("pengwynn/octokit", "another significant bug")
50
48
  expect(labels.color).to eq("ededed")
51
49
  expect(labels.name).to eq("V3 Addition")
@@ -59,7 +57,7 @@ describe Octokit::Client::Labels do
59
57
  stub_post("/repos/pengwynn/octokit/labels/V3+Addition").
60
58
  with(:body => {"color" => "ededed"},
61
59
  :headers => {'Content-Type'=>'application/json'}).
62
- to_return(:status => 200, :body => fixture('v3/label.json'))
60
+ to_return(json_response('label.json'))
63
61
 
64
62
  label = @client.update_label("pengwynn/octokit", "V3 Addition", {:color => 'ededed'})
65
63
  expect(label.color).to eq('ededed')
@@ -73,8 +71,8 @@ describe Octokit::Client::Labels do
73
71
  stub_delete("/repos/pengwynn/octokit/labels/V3+Transition").
74
72
  to_return(:status => 204)
75
73
 
76
- response = @client.delete_label!("pengwynn/octokit", "V3 Transition")
77
- expect(response.status).to eq(204)
74
+ result = @client.delete_label!("pengwynn/octokit", "V3 Transition")
75
+ expect(result).to be_true
78
76
  end
79
77
 
80
78
  end
@@ -83,7 +81,7 @@ describe Octokit::Client::Labels do
83
81
 
84
82
  it "removes a label from the specified issue" do
85
83
  stub_delete("/repos/pengwynn/octokit/issues/23/labels/V3+Transition").
86
- to_return(:status => 200, :body => fixture('v3/labels.json'), :headers => {})
84
+ to_return(json_response('labels.json'), :headers => {})
87
85
 
88
86
  response = @client.remove_label("pengwynn/octokit", 23, "V3 Transition")
89
87
  expect(response.last.name).to eq('Bug')
@@ -97,8 +95,8 @@ describe Octokit::Client::Labels do
97
95
  stub_delete("/repos/pengwynn/octokit/issues/23/labels").
98
96
  to_return(:status => 204)
99
97
 
100
- response = @client.remove_all_labels('pengwynn/octokit', 23)
101
- expect(response.status).to eq(204)
98
+ result = @client.remove_all_labels('pengwynn/octokit', 23)
99
+ expect(result).to be_true
102
100
  end
103
101
 
104
102
  end
@@ -106,9 +104,8 @@ describe Octokit::Client::Labels do
106
104
  describe ".add_labels_to_an_issue" do
107
105
  it "adds labels to a given issue" do
108
106
  stub_post("/repos/pengwynn/octokit/issues/42/labels").
109
- with(:body => '["V3 Transition","Bug"]',
110
- :headers => {'Accept'=>'*/*', 'Content-Type'=>'application/json'}).
111
- to_return(:status => 200, :body => fixture('v3/labels.json'), :headers => {})
107
+ with(:body => '["V3 Transition","Bug"]').
108
+ to_return(json_response('labels.json'), :headers => {})
112
109
 
113
110
  labels = @client.add_labels_to_an_issue('pengwynn/octokit', 42, ['V3 Transition', 'Bug'])
114
111
  expect(labels.first.name).to eq('V3 Transition')
@@ -119,9 +116,8 @@ describe Octokit::Client::Labels do
119
116
  describe ".replace_all_labels" do
120
117
  it "replaces all labels for an issue" do
121
118
  stub_put("/repos/pengwynn/octokit/issues/42/labels").
122
- with(:body => '["V3 Transition","V3 Adding"]',
123
- :headers => {'Accept'=>'*/*', 'Content-Type'=>'application/json'}).
124
- to_return(:status => 200, :body => fixture('v3/labels.json'), :headers => {})
119
+ with(:body => '["V3 Transition","V3 Adding"]').
120
+ to_return(json_response('labels.json'), :headers => {})
125
121
 
126
122
  labels = @client.replace_all_labels('pengwynn/octokit', 42, ['V3 Transition', 'V3 Adding'])
127
123
  expect(labels.first.name).to eq('V3 Transition')
@@ -131,7 +127,7 @@ describe Octokit::Client::Labels do
131
127
  describe ".lables_for_milestone" do
132
128
  it "returns all labels for a repository" do
133
129
  stub_get('/repos/pengwynn/octokit/milestones/2/labels').
134
- to_return(:status => 200, :body => fixture('v3/labels.json'), :headers => {})
130
+ to_return(json_response('labels.json'), :headers => {})
135
131
 
136
132
  labels = @client.labels_for_milestone('pengwynn/octokit', 2)
137
133
  expect(labels.size).to eq(3)
@@ -141,7 +137,7 @@ describe Octokit::Client::Labels do
141
137
  describe ".labels_for_issue" do
142
138
  it "returns all labels for a given issue" do
143
139
  stub_get("/repos/pengwynn/octokit/issues/37/labels").
144
- to_return(:status => 200, :body => fixture('v3/labels.json'), :headers => {})
140
+ to_return(json_response('labels.json'), :headers => {})
145
141
 
146
142
  labels = @client.labels_for_issue('pengwynn/octokit', 37)
147
143
  expect(labels.first.name).to eq('V3 Transition')