hybridgroup-octokit 0.6.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +4 -0
- data/.gemtest +0 -0
- data/.gitignore +24 -0
- data/.rspec +3 -0
- data/.travis.yml +6 -0
- data/Gemfile +3 -0
- data/LICENSE +20 -0
- data/README.markdown +73 -0
- data/Rakefile +8 -0
- data/changelog.markdown +42 -0
- data/lib/faraday/response/raise_error.rb +33 -0
- data/lib/octokit/client/authentication.rb +23 -0
- data/lib/octokit/client/commits.rb +16 -0
- data/lib/octokit/client/connection.rb +34 -0
- data/lib/octokit/client/issues.rb +60 -0
- data/lib/octokit/client/network.rb +15 -0
- data/lib/octokit/client/objects.rb +33 -0
- data/lib/octokit/client/organizations.rb +90 -0
- data/lib/octokit/client/pulls.rb +25 -0
- data/lib/octokit/client/repositories.rb +138 -0
- data/lib/octokit/client/request.rb +41 -0
- data/lib/octokit/client/timelines.rb +22 -0
- data/lib/octokit/client/users.rb +75 -0
- data/lib/octokit/client.rb +40 -0
- data/lib/octokit/configuration.rb +61 -0
- data/lib/octokit/repository.rb +39 -0
- data/lib/octokit/version.rb +3 -0
- data/lib/octokit.rb +53 -0
- data/octokit.gemspec +33 -0
- data/spec/faraday/response_spec.rb +34 -0
- data/spec/fixtures/blob.json +1 -0
- data/spec/fixtures/blob_metadata.json +1 -0
- data/spec/fixtures/blobs.json +1 -0
- data/spec/fixtures/branches.json +1 -0
- data/spec/fixtures/collaborators.json +1 -0
- data/spec/fixtures/comment.json +1 -0
- data/spec/fixtures/comments.json +1 -0
- data/spec/fixtures/commit.json +1 -0
- data/spec/fixtures/commits.json +1 -0
- data/spec/fixtures/contributors.json +1 -0
- data/spec/fixtures/delete_token.json +1 -0
- data/spec/fixtures/emails.json +1 -0
- data/spec/fixtures/followers.json +1 -0
- data/spec/fixtures/following.json +1 -0
- data/spec/fixtures/issue.json +1 -0
- data/spec/fixtures/issues.json +1 -0
- data/spec/fixtures/labels.json +1 -0
- data/spec/fixtures/languages.json +1 -0
- data/spec/fixtures/network.json +1 -0
- data/spec/fixtures/network_data.json +1 -0
- data/spec/fixtures/network_meta.json +1 -0
- data/spec/fixtures/organization.json +1 -0
- data/spec/fixtures/organizations.json +1 -0
- data/spec/fixtures/public_keys.json +1 -0
- data/spec/fixtures/pull.json +1 -0
- data/spec/fixtures/pulls.json +1 -0
- data/spec/fixtures/raw.txt +7 -0
- data/spec/fixtures/repositories.json +1 -0
- data/spec/fixtures/repository.json +1 -0
- data/spec/fixtures/tags.json +1 -0
- data/spec/fixtures/team.json +1 -0
- data/spec/fixtures/teams.json +1 -0
- data/spec/fixtures/timeline.json +1237 -0
- data/spec/fixtures/tree.json +1 -0
- data/spec/fixtures/tree_metadata.json +1 -0
- data/spec/fixtures/user.json +1 -0
- data/spec/fixtures/users.json +1 -0
- data/spec/fixtures/watchers.json +1 -0
- data/spec/helper.rb +64 -0
- data/spec/octokit/client/commits_spec.rb +32 -0
- data/spec/octokit/client/issues_spec.rb +154 -0
- data/spec/octokit/client/network_spec.rb +32 -0
- data/spec/octokit/client/objects_spec.rb +81 -0
- data/spec/octokit/client/organizations_spec.rb +234 -0
- data/spec/octokit/client/pulls_spec.rb +44 -0
- data/spec/octokit/client/repositories_spec.rb +331 -0
- data/spec/octokit/client/timelines_spec.rb +42 -0
- data/spec/octokit/client/users_spec.rb +274 -0
- data/spec/octokit/client_spec.rb +12 -0
- data/spec/octokit_spec.rb +15 -0
- data/spec/repository_spec.rb +54 -0
- metadata +403 -0
@@ -0,0 +1,81 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require 'helper'
|
3
|
+
|
4
|
+
describe Octokit::Client::Objects do
|
5
|
+
|
6
|
+
before do
|
7
|
+
@client = Octokit::Client.new(:login => 'sferik')
|
8
|
+
end
|
9
|
+
|
10
|
+
describe ".tree" do
|
11
|
+
|
12
|
+
it "should return a tree" do
|
13
|
+
stub_get("tree/show/sferik/rails_admin/3cdfabd973bc3caac209cba903cfdb3bf6636bcd").
|
14
|
+
to_return(:body => fixture("tree.json"))
|
15
|
+
tree = @client.tree("sferik/rails_admin", "3cdfabd973bc3caac209cba903cfdb3bf6636bcd")
|
16
|
+
tree.first.name.should == ".gitignore"
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
describe ".blob" do
|
22
|
+
|
23
|
+
it "should return a blob" do
|
24
|
+
stub_get("blob/show/sferik/rails_admin/3cdfabd973bc3caac209cba903cfdb3bf6636bcd/README.mkd").
|
25
|
+
to_return(:body => fixture("blob.json"))
|
26
|
+
blob = @client.blob("sferik/rails_admin", "3cdfabd973bc3caac209cba903cfdb3bf6636bcd", "README.mkd")
|
27
|
+
blob.name.should == "README.mkd"
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
describe ".blobs" do
|
33
|
+
|
34
|
+
it "should return blobs" do
|
35
|
+
stub_get("blob/all/sferik/rails_admin/3cdfabd973bc3caac209cba903cfdb3bf6636bcd").
|
36
|
+
to_return(:body => fixture("blobs.json"))
|
37
|
+
blobs = @client.blobs("sferik/rails_admin", "3cdfabd973bc3caac209cba903cfdb3bf6636bcd")
|
38
|
+
blobs[".gitignore"].should == "5efe0eb47a773fa6ea84a0bf190ee218b6a31ead"
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
describe ".blob_metadata" do
|
44
|
+
|
45
|
+
it "should return blob metadata" do
|
46
|
+
stub_get("blob/full/sferik/rails_admin/3cdfabd973bc3caac209cba903cfdb3bf6636bcd").
|
47
|
+
to_return(:body => fixture("blob_metadata.json"))
|
48
|
+
blob_metadata = @client.blob_metadata("sferik/rails_admin", "3cdfabd973bc3caac209cba903cfdb3bf6636bcd")
|
49
|
+
blob_metadata.first.name.should == ".gitignore"
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
|
54
|
+
describe ".tree_metadata" do
|
55
|
+
|
56
|
+
it "should return tree metadata" do
|
57
|
+
stub_get("tree/full/sferik/rails_admin/3cdfabd973bc3caac209cba903cfdb3bf6636bcd").
|
58
|
+
to_return(:body => fixture("tree_metadata.json"))
|
59
|
+
tree_metadata = @client.tree_metadata("sferik/rails_admin", "3cdfabd973bc3caac209cba903cfdb3bf6636bcd")
|
60
|
+
tree_metadata.first.name.should == ".gitignore"
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
|
65
|
+
describe ".raw" do
|
66
|
+
|
67
|
+
it "should return raw data" do
|
68
|
+
stub_get("blob/show/sferik/rails_admin/3cdfabd973bc3caac209cba903cfdb3bf6636bcd").
|
69
|
+
to_return(:body => fixture("raw.txt"))
|
70
|
+
raw = @client.raw("sferik/rails_admin", "3cdfabd973bc3caac209cba903cfdb3bf6636bcd")
|
71
|
+
lambda {
|
72
|
+
::MultiJson.decode(raw)
|
73
|
+
}.should raise_error
|
74
|
+
lambda {
|
75
|
+
::MultiXml.decode(raw)
|
76
|
+
}.should raise_error
|
77
|
+
end
|
78
|
+
|
79
|
+
end
|
80
|
+
|
81
|
+
end
|
@@ -0,0 +1,234 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require 'helper'
|
3
|
+
|
4
|
+
describe Octokit::Client::Organizations do
|
5
|
+
|
6
|
+
before do
|
7
|
+
@client = Octokit::Client.new(:login => 'sferik')
|
8
|
+
end
|
9
|
+
|
10
|
+
describe ".organization" do
|
11
|
+
|
12
|
+
it "should return an organization" do
|
13
|
+
stub_get("organizations/codeforamerica").
|
14
|
+
to_return(:body => fixture("organization.json"))
|
15
|
+
organization = @client.organization("codeforamerica")
|
16
|
+
organization.name.should == "Code For America"
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
describe ".update_organization" do
|
22
|
+
|
23
|
+
it "should update an organization" do
|
24
|
+
stub_put("organizations/codeforamerica").
|
25
|
+
with(:name => "Code For America").
|
26
|
+
to_return(:body => fixture("organization.json"))
|
27
|
+
organization = @client.update_organization("codeforamerica", {:name => "Code For America"})
|
28
|
+
organization.name.should == "Code For America"
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
describe ".organizations" do
|
34
|
+
|
35
|
+
context "with an org passed" do
|
36
|
+
|
37
|
+
it "should return all organizations for a user" do
|
38
|
+
stub_get("user/show/sferik/organizations").
|
39
|
+
to_return(:body => fixture("organizations.json"))
|
40
|
+
organizations = @client.organizations("sferik")
|
41
|
+
organizations.first.name.should == "Hubcap"
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
context "without an org passed" do
|
47
|
+
|
48
|
+
it "should return all organizations for a user" do
|
49
|
+
stub_get("organizations").
|
50
|
+
to_return(:body => fixture("organizations.json"))
|
51
|
+
organizations = @client.organizations
|
52
|
+
organizations.first.name.should == "Hubcap"
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
|
59
|
+
describe ".organization_repositories" do
|
60
|
+
|
61
|
+
context "with an org passed" do
|
62
|
+
|
63
|
+
it "should return all public repositories for an organization" do
|
64
|
+
stub_get("organizations/codeforamerica/public_repositories").
|
65
|
+
to_return(:body => fixture("repositories.json"))
|
66
|
+
repositories = @client.organization_repositories("codeforamerica")
|
67
|
+
repositories.first.name.should == "One40Proof"
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
71
|
+
|
72
|
+
context "without an org passed" do
|
73
|
+
|
74
|
+
it "should return all organization repositories for a user" do
|
75
|
+
stub_get("organizations/repositories").
|
76
|
+
to_return(:body => fixture("repositories.json"))
|
77
|
+
repositories = @client.organization_repositories
|
78
|
+
repositories.first.name.should == "One40Proof"
|
79
|
+
end
|
80
|
+
|
81
|
+
end
|
82
|
+
|
83
|
+
end
|
84
|
+
|
85
|
+
describe ".organization_members" do
|
86
|
+
|
87
|
+
it "should return all public members of an organization" do
|
88
|
+
stub_get("organizations/codeforamerica/public_members").
|
89
|
+
to_return(:body => fixture("users.json"))
|
90
|
+
users = @client.organization_members("codeforamerica")
|
91
|
+
users.first.name.should == "Erik Michaels-Ober"
|
92
|
+
end
|
93
|
+
|
94
|
+
end
|
95
|
+
|
96
|
+
describe ".organization_teams" do
|
97
|
+
|
98
|
+
it "should return all teams for an organization" do
|
99
|
+
stub_get("organizations/codeforamerica/teams").
|
100
|
+
to_return(:body => fixture("teams.json"))
|
101
|
+
teams = @client.organization_teams("codeforamerica")
|
102
|
+
teams.first.name.should == "Fellows"
|
103
|
+
end
|
104
|
+
|
105
|
+
end
|
106
|
+
|
107
|
+
describe ".create_team" do
|
108
|
+
|
109
|
+
it "should create a team" do
|
110
|
+
stub_post("organizations/codeforamerica/teams").
|
111
|
+
with(:name => "Fellows").
|
112
|
+
to_return(:body => fixture("team.json"))
|
113
|
+
team = @client.create_team("codeforamerica", {:name => "Fellows"})
|
114
|
+
team.name.should == "Fellows"
|
115
|
+
end
|
116
|
+
|
117
|
+
end
|
118
|
+
|
119
|
+
describe ".team" do
|
120
|
+
|
121
|
+
it "should return a team" do
|
122
|
+
stub_get("teams/32598").
|
123
|
+
to_return(:body => fixture("team.json"))
|
124
|
+
team = @client.team(32598)
|
125
|
+
team.name.should == "Fellows"
|
126
|
+
end
|
127
|
+
|
128
|
+
end
|
129
|
+
|
130
|
+
describe ".update_team" do
|
131
|
+
|
132
|
+
it "should update a team" do
|
133
|
+
stub_put("teams/32598").
|
134
|
+
with(:name => "Fellows").
|
135
|
+
to_return(:body => fixture("team.json"))
|
136
|
+
team = @client.update_team(32598, :name => "Fellows")
|
137
|
+
team.name.should == "Fellows"
|
138
|
+
end
|
139
|
+
|
140
|
+
end
|
141
|
+
|
142
|
+
describe ".delete_team" do
|
143
|
+
|
144
|
+
it "should delete a team" do
|
145
|
+
stub_delete("teams/32598").
|
146
|
+
to_return(:body => fixture("team.json"))
|
147
|
+
team = @client.delete_team(32598)
|
148
|
+
team.name.should == "Fellows"
|
149
|
+
end
|
150
|
+
|
151
|
+
end
|
152
|
+
|
153
|
+
describe ".delete_team" do
|
154
|
+
|
155
|
+
it "should delete a team" do
|
156
|
+
stub_delete("teams/32598").
|
157
|
+
to_return(:body => fixture("team.json"))
|
158
|
+
team = @client.delete_team(32598)
|
159
|
+
team.name.should == "Fellows"
|
160
|
+
end
|
161
|
+
|
162
|
+
end
|
163
|
+
|
164
|
+
describe ".team_members" do
|
165
|
+
|
166
|
+
it "should return team members" do
|
167
|
+
stub_get("teams/32598/members").
|
168
|
+
to_return(:body => fixture("users.json"))
|
169
|
+
users = @client.team_members(32598)
|
170
|
+
users.first.name.should == "Erik Michaels-Ober"
|
171
|
+
end
|
172
|
+
|
173
|
+
end
|
174
|
+
|
175
|
+
describe ".add_team_member" do
|
176
|
+
|
177
|
+
it "should add a team member" do
|
178
|
+
stub_post("teams/32598/members").
|
179
|
+
with(:name => "sferik").
|
180
|
+
to_return(:body => fixture("user.json"))
|
181
|
+
user = @client.add_team_member(32598, "sferik")
|
182
|
+
user.name.should == "Erik Michaels-Ober"
|
183
|
+
end
|
184
|
+
|
185
|
+
end
|
186
|
+
|
187
|
+
describe ".remove_team_member" do
|
188
|
+
|
189
|
+
it "should remove a team member" do
|
190
|
+
stub_delete("teams/32598/members").
|
191
|
+
with(:query => {:name => "sferik"}).
|
192
|
+
to_return(:body => fixture("user.json"))
|
193
|
+
user = @client.remove_team_member(32598, "sferik")
|
194
|
+
user.name.should == "Erik Michaels-Ober"
|
195
|
+
end
|
196
|
+
|
197
|
+
end
|
198
|
+
|
199
|
+
describe ".team_repositories" do
|
200
|
+
|
201
|
+
it "should return team repositories" do
|
202
|
+
stub_get("teams/32598/repositories").
|
203
|
+
to_return(:body => fixture("repositories.json"))
|
204
|
+
repositories = @client.team_repositories(32598)
|
205
|
+
repositories.first.name.should == "One40Proof"
|
206
|
+
end
|
207
|
+
|
208
|
+
end
|
209
|
+
|
210
|
+
describe ".add_team_repository" do
|
211
|
+
|
212
|
+
it "should add a team repository" do
|
213
|
+
stub_post("teams/32598/repositories").
|
214
|
+
with(:name => "reddavis/One40Proof").
|
215
|
+
to_return(:body => fixture("repositories.json"))
|
216
|
+
repositories = @client.add_team_repository(32598, "reddavis/One40Proof")
|
217
|
+
repositories.first.name.should == "One40Proof"
|
218
|
+
end
|
219
|
+
|
220
|
+
end
|
221
|
+
|
222
|
+
describe ".remove_team_repository" do
|
223
|
+
|
224
|
+
it "should remove a team repository" do
|
225
|
+
stub_delete("teams/32598/repositories").
|
226
|
+
with(:query => {:name => "reddavis/One40Proof"}).
|
227
|
+
to_return(:body => fixture("repositories.json"))
|
228
|
+
repositories = @client.remove_team_repository(32598, "reddavis/One40Proof")
|
229
|
+
repositories.first.name.should == "One40Proof"
|
230
|
+
end
|
231
|
+
|
232
|
+
end
|
233
|
+
|
234
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require 'helper'
|
3
|
+
|
4
|
+
describe Octokit::Client::Pulls do
|
5
|
+
|
6
|
+
before do
|
7
|
+
@client = Octokit::Client.new(:login => 'sferik')
|
8
|
+
end
|
9
|
+
|
10
|
+
describe ".create_pull_request" do
|
11
|
+
|
12
|
+
it "should create a pull request" do
|
13
|
+
stub_post("pulls/sferik/rails_admin").
|
14
|
+
with(:pull => {:base => "master", :head => "pengwynn:master", :title => "Title", :body => "Body"}).
|
15
|
+
to_return(:body => fixture("pulls.json"))
|
16
|
+
issues = @client.create_pull_request("sferik/rails_admin", "master", "pengwynn:master", "Title", "Body")
|
17
|
+
issues.first.number.should == 251
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
describe ".pull_requests" do
|
23
|
+
|
24
|
+
it "should return all pull requests" do
|
25
|
+
stub_get("pulls/sferik/rails_admin/open").
|
26
|
+
to_return(:body => fixture("pulls.json"))
|
27
|
+
pulls = @client.pulls("sferik/rails_admin")
|
28
|
+
pulls.first.number.should == 251
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
describe ".pull_request" do
|
34
|
+
|
35
|
+
it "should return a pull request" do
|
36
|
+
stub_get("pulls/sferik/rails_admin/251").
|
37
|
+
to_return(:body => fixture("pull.json"))
|
38
|
+
pull = @client.pull("sferik/rails_admin", 251)
|
39
|
+
pull.number.should == 251
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
@@ -0,0 +1,331 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require 'helper'
|
3
|
+
|
4
|
+
describe Octokit::Client::Repositories do
|
5
|
+
|
6
|
+
before do
|
7
|
+
@client = Octokit::Client.new(:login => 'sferik')
|
8
|
+
end
|
9
|
+
|
10
|
+
describe ".search_user" do
|
11
|
+
|
12
|
+
it "should return matching repositories" do
|
13
|
+
stub_get("repos/search/One40Proof").
|
14
|
+
to_return(:body => fixture("repositories.json"))
|
15
|
+
repositories = @client.search_repositories("One40Proof")
|
16
|
+
repositories.first.name.should == "One40Proof"
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
describe ".repository" do
|
22
|
+
|
23
|
+
it "should return the matching repository" do
|
24
|
+
stub_get("repos/show/sferik/rails_admin").
|
25
|
+
to_return(:body => fixture("repository.json"))
|
26
|
+
repository = @client.repository("sferik/rails_admin")
|
27
|
+
repository.name.should == "rails_admin"
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
describe ".update_repository" do
|
33
|
+
|
34
|
+
it "should update the matching repository" do
|
35
|
+
description = "RailsAdmin is a Rails 3 engine that provides an easy-to-use interface for managing your data"
|
36
|
+
stub_post("repos/show/sferik/rails_admin").
|
37
|
+
with(:values => {:description => description}).
|
38
|
+
to_return(:body => fixture("repository.json"))
|
39
|
+
repository = @client.update_repository("sferik/rails_admin", :description => description)
|
40
|
+
repository.description.should == description
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
describe ".repositories" do
|
46
|
+
|
47
|
+
context "with a username passed" do
|
48
|
+
|
49
|
+
it "should return user's repositories" do
|
50
|
+
stub_get("repos/show/sferik").
|
51
|
+
to_return(:body => fixture("repositories.json"))
|
52
|
+
repositories = @client.repositories("sferik")
|
53
|
+
repositories.first.name.should == "One40Proof"
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
57
|
+
|
58
|
+
context "without a username passed" do
|
59
|
+
|
60
|
+
it "should return authenticated user's repositories" do
|
61
|
+
stub_get("repos/show/sferik").
|
62
|
+
to_return(:body => fixture("repositories.json"))
|
63
|
+
repositories = @client.repositories
|
64
|
+
repositories.first.name.should == "One40Proof"
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
70
|
+
|
71
|
+
describe ".watch" do
|
72
|
+
|
73
|
+
it "should watch a repository" do
|
74
|
+
stub_post("repos/watch/sferik/rails_admin").
|
75
|
+
to_return(:body => fixture("repository.json"))
|
76
|
+
repository = @client.watch("sferik/rails_admin")
|
77
|
+
repository.name.should == "rails_admin"
|
78
|
+
end
|
79
|
+
|
80
|
+
end
|
81
|
+
|
82
|
+
describe ".unwatch" do
|
83
|
+
|
84
|
+
it "should unwatch a repository" do
|
85
|
+
stub_post("repos/unwatch/sferik/rails_admin").
|
86
|
+
to_return(:body => fixture("repository.json"))
|
87
|
+
repository = @client.unwatch("sferik/rails_admin")
|
88
|
+
repository.name.should == "rails_admin"
|
89
|
+
end
|
90
|
+
|
91
|
+
end
|
92
|
+
|
93
|
+
describe ".fork" do
|
94
|
+
|
95
|
+
it "should fork a repository" do
|
96
|
+
stub_post("repos/fork/sferik/rails_admin").
|
97
|
+
to_return(:body => fixture("repository.json"))
|
98
|
+
repository = @client.fork("sferik/rails_admin")
|
99
|
+
repository.name.should == "rails_admin"
|
100
|
+
end
|
101
|
+
|
102
|
+
end
|
103
|
+
|
104
|
+
describe ".create_repository" do
|
105
|
+
|
106
|
+
it "should create a repository" do
|
107
|
+
stub_post("repos/create").
|
108
|
+
with(:name => "rails_admin").
|
109
|
+
to_return(:body => fixture("repository.json"))
|
110
|
+
repository = @client.create_repository("rails_admin")
|
111
|
+
repository.name.should == "rails_admin"
|
112
|
+
end
|
113
|
+
|
114
|
+
end
|
115
|
+
|
116
|
+
describe ".delete_repository" do
|
117
|
+
|
118
|
+
it "should return a delete token" do
|
119
|
+
stub_post("repos/delete/sferik/rails_admin").
|
120
|
+
to_return(:body => fixture("delete_token.json"))
|
121
|
+
delete_token = @client.delete_repository("sferik/rails_admin")
|
122
|
+
delete_token.should == "uhihwkkkzu"
|
123
|
+
end
|
124
|
+
|
125
|
+
end
|
126
|
+
|
127
|
+
describe ".delete_repository" do
|
128
|
+
|
129
|
+
it "should delete a repository" do
|
130
|
+
stub_post("repos/delete/sferik/rails_admin").
|
131
|
+
to_return(:body => fixture("repository.json"))
|
132
|
+
repository = @client.delete_repository("sferik/rails_admin")
|
133
|
+
repository.name.should == "rails_admin"
|
134
|
+
end
|
135
|
+
|
136
|
+
end
|
137
|
+
|
138
|
+
describe ".set_private" do
|
139
|
+
|
140
|
+
it "should set a repository private" do
|
141
|
+
stub_post("repos/set/private/sferik/rails_admin").
|
142
|
+
to_return(:body => fixture("repository.json"))
|
143
|
+
repository = @client.set_private("sferik/rails_admin")
|
144
|
+
repository.name.should == "rails_admin"
|
145
|
+
end
|
146
|
+
|
147
|
+
end
|
148
|
+
|
149
|
+
describe ".set_public" do
|
150
|
+
|
151
|
+
it "should set a repository public" do
|
152
|
+
stub_post("repos/set/public/sferik/rails_admin").
|
153
|
+
to_return(:body => fixture("repository.json"))
|
154
|
+
repository = @client.set_public("sferik/rails_admin")
|
155
|
+
repository.name.should == "rails_admin"
|
156
|
+
end
|
157
|
+
|
158
|
+
end
|
159
|
+
|
160
|
+
describe ".deploy_keys" do
|
161
|
+
|
162
|
+
it "should return a repository's deploy keys" do
|
163
|
+
stub_get("repos/keys/sferik/rails_admin").
|
164
|
+
to_return(:body => fixture("public_keys.json"))
|
165
|
+
public_keys = @client.deploy_keys("sferik/rails_admin")
|
166
|
+
public_keys.first.id.should == 103205
|
167
|
+
end
|
168
|
+
|
169
|
+
end
|
170
|
+
|
171
|
+
describe ".add_deploy_key" do
|
172
|
+
|
173
|
+
it "should add a repository deploy keys" do
|
174
|
+
stub_post("repos/key/sferik/rails_admin/add").
|
175
|
+
with(:title => "Moss", :key => "ssh-dss AAAAB3NzaC1kc3MAAACBAJz7HanBa18ad1YsdFzHO5Wy1/WgXd4BV+czbKq7q23jungbfjN3eo2a0SVdxux8GG+RZ9ia90VD/X+PE4s3LV60oXZ7PDAuyPO1CTF0TaDoKf9mPaHcPa6agMJVocMsgBgwviWT1Q9VgN1SccDsYVDtxkIAwuw25YeHZlG6myx1AAAAFQCgW+OvXWUdUJPBGkRJ8ML7uf0VHQAAAIAlP5G96tTss0SKYVSCJCyocn9cyGQdNjxah4/aYuYFTbLI1rxk7sr/AkZfJNIoF2UFyO5STbbratykIQGUPdUBg1a2t72bu31x+4ZYJMngNsG/AkZ2oqLiH6dJKHD7PFx2oSPalogwsUV7iSMIZIYaPa03A9763iFsN0qJjaed+gAAAIBxz3Prxdzt/os4XGXSMNoWcS03AFC/05NOkoDMrXxQnTTpp1wrOgyRqEnKz15qC5dWk1ynzK+LJXHDZGA8lXPfCjHpJO3zrlZ/ivvLhgPdDpt13MAhIJFH06hTal0woxbk/fIdY71P3kbgXC0Ppx/0S7BC+VxqRCA4/wcM+BoDbA== host").
|
176
|
+
to_return(:body => fixture("public_keys.json"))
|
177
|
+
public_keys = @client.add_deploy_key("sferik/rails_admin", "Moss", "ssh-dss AAAAB3NzaC1kc3MAAACBAJz7HanBa18ad1YsdFzHO5Wy1/WgXd4BV+czbKq7q23jungbfjN3eo2a0SVdxux8GG+RZ9ia90VD/X+PE4s3LV60oXZ7PDAuyPO1CTF0TaDoKf9mPaHcPa6agMJVocMsgBgwviWT1Q9VgN1SccDsYVDtxkIAwuw25YeHZlG6myx1AAAAFQCgW+OvXWUdUJPBGkRJ8ML7uf0VHQAAAIAlP5G96tTss0SKYVSCJCyocn9cyGQdNjxah4/aYuYFTbLI1rxk7sr/AkZfJNIoF2UFyO5STbbratykIQGUPdUBg1a2t72bu31x+4ZYJMngNsG/AkZ2oqLiH6dJKHD7PFx2oSPalogwsUV7iSMIZIYaPa03A9763iFsN0qJjaed+gAAAIBxz3Prxdzt/os4XGXSMNoWcS03AFC/05NOkoDMrXxQnTTpp1wrOgyRqEnKz15qC5dWk1ynzK+LJXHDZGA8lXPfCjHpJO3zrlZ/ivvLhgPdDpt13MAhIJFH06hTal0woxbk/fIdY71P3kbgXC0Ppx/0S7BC+VxqRCA4/wcM+BoDbA== host")
|
178
|
+
public_keys.first.id.should == 103205
|
179
|
+
end
|
180
|
+
|
181
|
+
end
|
182
|
+
|
183
|
+
describe ".remove_deploy_key" do
|
184
|
+
|
185
|
+
it "should remove a repository deploy keys" do
|
186
|
+
stub_post("repos/key/sferik/rails_admin/remove").
|
187
|
+
with(:id => 103205).
|
188
|
+
to_return(:body => fixture("public_keys.json"))
|
189
|
+
public_keys = @client.remove_deploy_key("sferik/rails_admin", 103205)
|
190
|
+
public_keys.first.id.should == 103205
|
191
|
+
end
|
192
|
+
|
193
|
+
end
|
194
|
+
|
195
|
+
describe ".collaborators" do
|
196
|
+
|
197
|
+
it "should return a repository's collaborators" do
|
198
|
+
stub_get("repos/show/sferik/rails_admin/collaborators").
|
199
|
+
to_return(:body => fixture("collaborators.json"))
|
200
|
+
collaborators = @client.collaborators("sferik/rails_admin")
|
201
|
+
collaborators.first.should == "sferik"
|
202
|
+
end
|
203
|
+
|
204
|
+
end
|
205
|
+
|
206
|
+
describe ".add_collaborator" do
|
207
|
+
|
208
|
+
it "should add a repository collaborators" do
|
209
|
+
stub_post("repos/collaborators/sferik/rails_admin/add/sferik").
|
210
|
+
to_return(:body => fixture("collaborators.json"))
|
211
|
+
collaborators = @client.add_collaborator("sferik/rails_admin", "sferik")
|
212
|
+
collaborators.first.should == "sferik"
|
213
|
+
end
|
214
|
+
|
215
|
+
end
|
216
|
+
|
217
|
+
describe ".remove_collaborator" do
|
218
|
+
|
219
|
+
it "should remove a repository collaborators" do
|
220
|
+
stub_post("repos/collaborators/sferik/rails_admin/remove/sferik").
|
221
|
+
to_return(:body => fixture("collaborators.json"))
|
222
|
+
collaborators = @client.remove_collaborator("sferik/rails_admin", "sferik")
|
223
|
+
collaborators.first.should == "sferik"
|
224
|
+
end
|
225
|
+
|
226
|
+
end
|
227
|
+
|
228
|
+
describe ".pushable" do
|
229
|
+
|
230
|
+
it "should return all pushable repositories" do
|
231
|
+
stub_get("repos/pushable").
|
232
|
+
to_return(:body => fixture("repositories.json"))
|
233
|
+
repositories = @client.pushable
|
234
|
+
repositories.first.name.should == "One40Proof"
|
235
|
+
end
|
236
|
+
|
237
|
+
end
|
238
|
+
|
239
|
+
describe ".repository_teams" do
|
240
|
+
|
241
|
+
it "should return all repository teams" do
|
242
|
+
stub_get("repos/show/codeforamerica/open311/teams").
|
243
|
+
to_return(:body => fixture("teams.json"))
|
244
|
+
teams = @client.repository_teams("codeforamerica/open311")
|
245
|
+
teams.first.name.should == "Fellows"
|
246
|
+
end
|
247
|
+
|
248
|
+
end
|
249
|
+
|
250
|
+
describe ".contributors" do
|
251
|
+
|
252
|
+
context "with anonymous users" do
|
253
|
+
|
254
|
+
it "should return all repository contributors" do
|
255
|
+
stub_get("repos/show/sferik/rails_admin/contributors/anon").
|
256
|
+
to_return(:body => fixture("contributors.json"))
|
257
|
+
contributors = @client.contributors("sferik/rails_admin", true)
|
258
|
+
contributors.first.name.should == "Erik Michaels-Ober"
|
259
|
+
end
|
260
|
+
|
261
|
+
end
|
262
|
+
|
263
|
+
context "without anonymous users" do
|
264
|
+
|
265
|
+
it "should return all repository contributors" do
|
266
|
+
stub_get("repos/show/sferik/rails_admin/contributors").
|
267
|
+
to_return(:body => fixture("contributors.json"))
|
268
|
+
contributors = @client.contributors("sferik/rails_admin")
|
269
|
+
contributors.first.name.should == "Erik Michaels-Ober"
|
270
|
+
end
|
271
|
+
|
272
|
+
end
|
273
|
+
|
274
|
+
end
|
275
|
+
|
276
|
+
describe ".watchers" do
|
277
|
+
|
278
|
+
it "should return all repository watchers" do
|
279
|
+
stub_get("repos/show/sferik/rails_admin/watchers").
|
280
|
+
to_return(:body => fixture("watchers.json"))
|
281
|
+
watchers = @client.watchers("sferik/rails_admin")
|
282
|
+
watchers.first.should == "sferik"
|
283
|
+
end
|
284
|
+
|
285
|
+
end
|
286
|
+
|
287
|
+
describe ".network" do
|
288
|
+
|
289
|
+
it "should return a repository's network" do
|
290
|
+
stub_get("repos/show/sferik/rails_admin/network").
|
291
|
+
to_return(:body => fixture("network.json"))
|
292
|
+
network = @client.network("sferik/rails_admin")
|
293
|
+
network.first.owner.should == "sferik"
|
294
|
+
end
|
295
|
+
|
296
|
+
end
|
297
|
+
|
298
|
+
describe ".languages" do
|
299
|
+
|
300
|
+
it "should return a repository's languages" do
|
301
|
+
stub_get("repos/show/sferik/rails_admin/languages").
|
302
|
+
to_return(:body => fixture("languages.json"))
|
303
|
+
languages = @client.languages("sferik/rails_admin")
|
304
|
+
languages["Ruby"].should == 205046
|
305
|
+
end
|
306
|
+
|
307
|
+
end
|
308
|
+
|
309
|
+
describe ".tags" do
|
310
|
+
|
311
|
+
it "should return a repository's tags" do
|
312
|
+
stub_get("repos/show/pengwynn/octokit/tags").
|
313
|
+
to_return(:body => fixture("tags.json"))
|
314
|
+
tags = @client.tags("pengwynn/octokit")
|
315
|
+
tags["v0.0.1"].should == "0d7a03f2035ecd74e4d6eb9be58865c2a688ee55"
|
316
|
+
end
|
317
|
+
|
318
|
+
end
|
319
|
+
|
320
|
+
describe ".branches" do
|
321
|
+
|
322
|
+
it "should return a repository's branches" do
|
323
|
+
stub_get("repos/show/pengwynn/octokit/branches").
|
324
|
+
to_return(:body => fixture("branches.json"))
|
325
|
+
branches = @client.branches("pengwynn/octokit")
|
326
|
+
branches["master"].should == "4d9a9e9ca183bab1c3d0accf1d53edd85bd6200f"
|
327
|
+
end
|
328
|
+
|
329
|
+
end
|
330
|
+
|
331
|
+
end
|