github_api 0.3.4 → 0.3.5
Sign up to get free protection for your applications and to get access to all the features.
- metadata +4 -140
- data/LICENSE.txt +0 -20
- data/README.rdoc +0 -228
- data/Rakefile +0 -52
- data/features/github_api.feature +0 -50
- data/features/step_definitions/github_api_steps.rb +0 -11
- data/features/support/env.rb +0 -13
- data/lib/github_api.rb +0 -73
- data/lib/github_api/api.rb +0 -175
- data/lib/github_api/api/utils.rb +0 -9
- data/lib/github_api/authorization.rb +0 -73
- data/lib/github_api/authorizations.rb +0 -119
- data/lib/github_api/cache_control.rb +0 -19
- data/lib/github_api/client.rb +0 -55
- data/lib/github_api/compatibility.rb +0 -23
- data/lib/github_api/configuration.rb +0 -96
- data/lib/github_api/connection.rb +0 -81
- data/lib/github_api/core_ext/array.rb +0 -14
- data/lib/github_api/core_ext/hash.rb +0 -42
- data/lib/github_api/error.rb +0 -35
- data/lib/github_api/events.rb +0 -202
- data/lib/github_api/gists.rb +0 -200
- data/lib/github_api/gists/comments.rb +0 -86
- data/lib/github_api/git_data.rb +0 -26
- data/lib/github_api/git_data/blobs.rb +0 -51
- data/lib/github_api/git_data/commits.rb +0 -78
- data/lib/github_api/git_data/references.rb +0 -113
- data/lib/github_api/git_data/tags.rb +0 -78
- data/lib/github_api/git_data/trees.rb +0 -89
- data/lib/github_api/issues.rb +0 -215
- data/lib/github_api/issues/comments.rb +0 -110
- data/lib/github_api/issues/events.rb +0 -50
- data/lib/github_api/issues/labels.rb +0 -191
- data/lib/github_api/issues/milestones.rb +0 -119
- data/lib/github_api/mime_type.rb +0 -55
- data/lib/github_api/orgs.rb +0 -95
- data/lib/github_api/orgs/members.rb +0 -120
- data/lib/github_api/orgs/teams.rb +0 -245
- data/lib/github_api/pull_requests.rb +0 -224
- data/lib/github_api/pull_requests/comments.rb +0 -144
- data/lib/github_api/repos.rb +0 -286
- data/lib/github_api/repos/collaborators.rb +0 -81
- data/lib/github_api/repos/commits.rb +0 -180
- data/lib/github_api/repos/downloads.rb +0 -155
- data/lib/github_api/repos/forks.rb +0 -48
- data/lib/github_api/repos/hooks.rb +0 -173
- data/lib/github_api/repos/keys.rb +0 -104
- data/lib/github_api/repos/pub_sub_hubbub.rb +0 -102
- data/lib/github_api/repos/watching.rb +0 -94
- data/lib/github_api/request.rb +0 -84
- data/lib/github_api/request/basic_auth.rb +0 -31
- data/lib/github_api/request/caching.rb +0 -33
- data/lib/github_api/request/oauth2.rb +0 -33
- data/lib/github_api/response.rb +0 -28
- data/lib/github_api/response/helpers.rb +0 -14
- data/lib/github_api/response/jsonize.rb +0 -26
- data/lib/github_api/response/mashify.rb +0 -24
- data/lib/github_api/response/raise_error.rb +0 -33
- data/lib/github_api/result.rb +0 -42
- data/lib/github_api/users.rb +0 -84
- data/lib/github_api/users/emails.rb +0 -49
- data/lib/github_api/users/followers.rb +0 -98
- data/lib/github_api/users/keys.rb +0 -84
- data/lib/github_api/version.rb +0 -12
- data/spec/README.rdoc +0 -22
- data/spec/coverage_adapter.rb +0 -14
- data/spec/fixtures/auths/authorization.json +0 -14
- data/spec/fixtures/auths/authorizations.json +0 -16
- data/spec/fixtures/events/events.json +0 -29
- data/spec/fixtures/issues/issue.json +0 -56
- data/spec/fixtures/issues/issues.json +0 -58
- data/spec/fixtures/orgs/members.json +0 -9
- data/spec/fixtures/orgs/org.json +0 -18
- data/spec/fixtures/orgs/orgs.json +0 -8
- data/spec/fixtures/orgs/team.json +0 -8
- data/spec/fixtures/orgs/team_repos.json +0 -29
- data/spec/fixtures/orgs/teams.json +0 -7
- data/spec/fixtures/repos/branches.json +0 -9
- data/spec/fixtures/repos/collaborators.json +0 -8
- data/spec/fixtures/repos/commit.json +0 -53
- data/spec/fixtures/repos/commit_comment.json +0 -16
- data/spec/fixtures/repos/commit_comments.json +0 -18
- data/spec/fixtures/repos/commits.json +0 -27
- data/spec/fixtures/repos/contributors.json +0 -8
- data/spec/fixtures/repos/download.json +0 -10
- data/spec/fixtures/repos/download_s3.json +0 -21
- data/spec/fixtures/repos/downloads.json +0 -12
- data/spec/fixtures/repos/fork.json +0 -27
- data/spec/fixtures/repos/forks.json +0 -29
- data/spec/fixtures/repos/hook.json +0 -15
- data/spec/fixtures/repos/hooks.json +0 -10
- data/spec/fixtures/repos/key.json +0 -6
- data/spec/fixtures/repos/keys.json +0 -8
- data/spec/fixtures/repos/languages.json +0 -4
- data/spec/fixtures/repos/repo.json +0 -90
- data/spec/fixtures/repos/repo_comments.json +0 -18
- data/spec/fixtures/repos/repos.json +0 -29
- data/spec/fixtures/repos/tags.json +0 -11
- data/spec/fixtures/repos/teams.json +0 -7
- data/spec/fixtures/repos/watched.json +0 -29
- data/spec/fixtures/repos/watchers.json +0 -8
- data/spec/fixtures/users/user.json +0 -32
- data/spec/github/api_spec.rb +0 -25
- data/spec/github/authorization_spec.rb +0 -176
- data/spec/github/authorizations_spec.rb +0 -242
- data/spec/github/client_spec.rb +0 -50
- data/spec/github/core_ext/hash_spec.rb +0 -44
- data/spec/github/events_spec.rb +0 -491
- data/spec/github/gists/comments_spec.rb +0 -5
- data/spec/github/gists_spec.rb +0 -5
- data/spec/github/git_data/blobs_spec.rb +0 -5
- data/spec/github/git_data/commits_spec.rb +0 -5
- data/spec/github/git_data/references_spec.rb +0 -5
- data/spec/github/git_data/tags_spec.rb +0 -5
- data/spec/github/git_data/trees_spec.rb +0 -5
- data/spec/github/git_data_spec.rb +0 -5
- data/spec/github/issues/comments_spec.rb +0 -5
- data/spec/github/issues/events_spec.rb +0 -5
- data/spec/github/issues/labels_spec.rb +0 -5
- data/spec/github/issues/milestones_spec.rb +0 -5
- data/spec/github/issues_spec.rb +0 -287
- data/spec/github/mime_type_spec.rb +0 -70
- data/spec/github/orgs/members_spec.rb +0 -275
- data/spec/github/orgs/teams_spec.rb +0 -563
- data/spec/github/orgs_spec.rb +0 -160
- data/spec/github/repos/collaborators_spec.rb +0 -169
- data/spec/github/repos/commits_spec.rb +0 -424
- data/spec/github/repos/downloads_spec.rb +0 -236
- data/spec/github/repos/forks_spec.rb +0 -103
- data/spec/github/repos/hooks_spec.rb +0 -307
- data/spec/github/repos/keys_spec.rb +0 -216
- data/spec/github/repos/pub_sub_hubbub_spec.rb +0 -83
- data/spec/github/repos/watching_spec.rb +0 -222
- data/spec/github/repos_spec.rb +0 -571
- data/spec/github/result_spec.rb +0 -43
- data/spec/github/users_spec.rb +0 -140
- data/spec/github_spec.rb +0 -109
- data/spec/spec_helper.rb +0 -86
@@ -1,563 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Github::Orgs::Teams do
|
4
|
-
|
5
|
-
let(:github) { Github.new }
|
6
|
-
let(:team) { 'github' }
|
7
|
-
let(:member) { 'github' }
|
8
|
-
let(:org) { 'github' }
|
9
|
-
let(:user) { 'peter-murach' }
|
10
|
-
let(:repo) { 'github' }
|
11
|
-
|
12
|
-
describe "teams" do
|
13
|
-
context "resource found" do
|
14
|
-
before do
|
15
|
-
stub_get("/orgs/#{org}/teams").
|
16
|
-
to_return(:body => fixture('orgs/teams.json'), :status => 200, :headers => {:content_type => "application/json; charset=utf-8"})
|
17
|
-
end
|
18
|
-
|
19
|
-
it "should fail to get resource without org name" do
|
20
|
-
expect { github.orgs.teams nil }.to raise_error(ArgumentError)
|
21
|
-
end
|
22
|
-
|
23
|
-
it "should get the resources" do
|
24
|
-
github.orgs.teams org
|
25
|
-
a_get("/orgs/#{org}/teams").should have_been_made
|
26
|
-
end
|
27
|
-
|
28
|
-
it "should return array of resources" do
|
29
|
-
teams = github.orgs.teams org
|
30
|
-
teams.should be_an Array
|
31
|
-
teams.should have(1).items
|
32
|
-
end
|
33
|
-
|
34
|
-
it "should be a mash type" do
|
35
|
-
teams = github.orgs.teams org
|
36
|
-
teams.first.should be_a Hashie::Mash
|
37
|
-
end
|
38
|
-
|
39
|
-
it "should get teams information" do
|
40
|
-
teams = github.orgs.teams org
|
41
|
-
teams.first.name.should == 'Owners'
|
42
|
-
end
|
43
|
-
|
44
|
-
it "should yield to a block" do
|
45
|
-
github.orgs.should_receive(:teams).with(org).and_yield('web')
|
46
|
-
github.orgs.teams(org) { |param| 'web' }
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
context "resource not found" do
|
51
|
-
before do
|
52
|
-
stub_get("/orgs/#{org}/teams").
|
53
|
-
to_return(:body => fixture('orgs/teams.json'), :status => 404, :headers => {:content_type => "application/json; charset=utf-8"})
|
54
|
-
end
|
55
|
-
|
56
|
-
it "should return 404 with a message 'Not Found'" do
|
57
|
-
expect {
|
58
|
-
github.orgs.teams org
|
59
|
-
}.to raise_error(Github::ResourceNotFound)
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end # teams
|
63
|
-
|
64
|
-
describe "team" do
|
65
|
-
context "resource found" do
|
66
|
-
before do
|
67
|
-
stub_get("/teams/#{team}").
|
68
|
-
to_return(:body => fixture('orgs/team.json'), :status => 200, :headers => {:content_type => "application/json; charset=utf-8"})
|
69
|
-
end
|
70
|
-
|
71
|
-
it "should fail to get resource without org name" do
|
72
|
-
expect { github.orgs.team nil }.to raise_error(ArgumentError)
|
73
|
-
end
|
74
|
-
|
75
|
-
it "should get the resource" do
|
76
|
-
github.orgs.team team
|
77
|
-
a_get("/teams/#{team}").should have_been_made
|
78
|
-
end
|
79
|
-
|
80
|
-
it "should get team information" do
|
81
|
-
team_res = github.orgs.team team
|
82
|
-
team_res.id.should == 1
|
83
|
-
team_res.name.should == 'Owners'
|
84
|
-
end
|
85
|
-
|
86
|
-
it "should return mash" do
|
87
|
-
team_res = github.orgs.team team
|
88
|
-
team_res.should be_a Hashie::Mash
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
|
-
context "resource not found" do
|
93
|
-
before do
|
94
|
-
stub_get("/teams/#{team}").
|
95
|
-
to_return(:body => fixture('orgs/team.json'), :status => 404, :headers => {:content_type => "application/json; charset=utf-8"})
|
96
|
-
end
|
97
|
-
|
98
|
-
it "should fail to retrive resource" do
|
99
|
-
expect {
|
100
|
-
github.orgs.team team
|
101
|
-
}.to raise_error(Github::ResourceNotFound)
|
102
|
-
end
|
103
|
-
end
|
104
|
-
end # team
|
105
|
-
|
106
|
-
describe "create_team" do
|
107
|
-
let(:inputs) { { :name => 'new team', :permissions => 'push', :repo_names => [ 'github/dotfiles' ] }}
|
108
|
-
|
109
|
-
context "resouce created" do
|
110
|
-
before do
|
111
|
-
stub_post("/orgs/#{org}/teams").with(inputs).
|
112
|
-
to_return(:body => fixture('orgs/team.json'), :status => 201, :headers => {:content_type => "application/json; charset=utf-8"})
|
113
|
-
|
114
|
-
end
|
115
|
-
|
116
|
-
it "should fail to create resource if 'org_name' param is missing" do
|
117
|
-
expect { github.orgs.create_team nil, inputs }.to raise_error(ArgumentError)
|
118
|
-
end
|
119
|
-
|
120
|
-
it "should failt to create resource if 'name' input is missing" do
|
121
|
-
expect {
|
122
|
-
github.orgs.create_team org, inputs.except(:name)
|
123
|
-
}.to raise_error(ArgumentError)
|
124
|
-
end
|
125
|
-
|
126
|
-
it "should create resource successfully" do
|
127
|
-
github.orgs.create_team org, inputs
|
128
|
-
a_post("/orgs/#{org}/teams").with(inputs).should have_been_made
|
129
|
-
end
|
130
|
-
|
131
|
-
it "should return the resource" do
|
132
|
-
team = github.orgs.create_team org, inputs
|
133
|
-
team.should be_a Hashie::Mash
|
134
|
-
end
|
135
|
-
|
136
|
-
it "should get the team information" do
|
137
|
-
team = github.orgs.create_team org, inputs
|
138
|
-
team.name.should == 'Owners'
|
139
|
-
end
|
140
|
-
end
|
141
|
-
|
142
|
-
context "failed to create resource" do
|
143
|
-
before do
|
144
|
-
stub_post("/orgs/#{org}/teams").with(inputs).
|
145
|
-
to_return(:body => fixture('orgs/team.json'), :status => 404, :headers => {:content_type => "application/json; charset=utf-8"})
|
146
|
-
|
147
|
-
end
|
148
|
-
|
149
|
-
it "should faile to retrieve resource" do
|
150
|
-
expect {
|
151
|
-
github.orgs.create_team org, inputs
|
152
|
-
}.to raise_error(Github::ResourceNotFound)
|
153
|
-
end
|
154
|
-
end
|
155
|
-
end # create_team
|
156
|
-
|
157
|
-
describe "edit_team" do
|
158
|
-
let(:inputs) { { :name => 'new team', :permissions => 'push' } }
|
159
|
-
|
160
|
-
context "resouce edited" do
|
161
|
-
before do
|
162
|
-
stub_patch("/teams/#{team}").with(inputs).
|
163
|
-
to_return(:body => fixture('orgs/team.json'), :status => 201, :headers => {:content_type => "application/json; charset=utf-8"})
|
164
|
-
|
165
|
-
end
|
166
|
-
|
167
|
-
it "should fail to create resource if 'team name' param is missing" do
|
168
|
-
expect { github.orgs.edit_team nil, inputs }.to raise_error(ArgumentError)
|
169
|
-
end
|
170
|
-
|
171
|
-
it "should failt to create resource if 'name' input is missing" do
|
172
|
-
expect {
|
173
|
-
github.orgs.edit_team team, inputs.except(:name)
|
174
|
-
}.to raise_error(ArgumentError)
|
175
|
-
end
|
176
|
-
|
177
|
-
it "should create resource successfully" do
|
178
|
-
github.orgs.edit_team team, inputs
|
179
|
-
a_patch("/teams/#{team}").with(inputs).should have_been_made
|
180
|
-
end
|
181
|
-
|
182
|
-
it "should return the resource" do
|
183
|
-
edited_team = github.orgs.edit_team team, inputs
|
184
|
-
edited_team.should be_a Hashie::Mash
|
185
|
-
end
|
186
|
-
|
187
|
-
it "should get the team information" do
|
188
|
-
edited_team = github.orgs.edit_team team, inputs
|
189
|
-
edited_team.name.should == 'Owners'
|
190
|
-
end
|
191
|
-
end
|
192
|
-
|
193
|
-
context "failed to create resource" do
|
194
|
-
before do
|
195
|
-
stub_patch("/teams/#{team}").with(inputs).
|
196
|
-
to_return(:body => fixture('orgs/team.json'), :status => 404, :headers => {:content_type => "application/json; charset=utf-8"})
|
197
|
-
|
198
|
-
end
|
199
|
-
|
200
|
-
it "should faile to retrieve resource" do
|
201
|
-
expect {
|
202
|
-
github.orgs.edit_team team, inputs
|
203
|
-
}.to raise_error(Github::ResourceNotFound)
|
204
|
-
end
|
205
|
-
end
|
206
|
-
end # edit_team
|
207
|
-
|
208
|
-
describe "delete_team" do
|
209
|
-
let(:team_id) { 1 }
|
210
|
-
|
211
|
-
context "resource edited successfully" do
|
212
|
-
before do
|
213
|
-
stub_delete("/teams/#{team}").
|
214
|
-
to_return(:body => '', :status => 204, :headers => { :content_type => "application/json; charset=utf-8"})
|
215
|
-
end
|
216
|
-
|
217
|
-
it "should fail to delete without 'team_id' parameter" do
|
218
|
-
github.user, github.repo = nil, nil
|
219
|
-
expect { github.orgs.delete_team }.to raise_error(ArgumentError)
|
220
|
-
end
|
221
|
-
|
222
|
-
it "should delete the resource" do
|
223
|
-
github.orgs.delete_team team
|
224
|
-
a_delete("/teams/#{team}").should have_been_made
|
225
|
-
end
|
226
|
-
end
|
227
|
-
|
228
|
-
context "failed to edit resource" do
|
229
|
-
before do
|
230
|
-
stub_delete("/teams/#{team}").
|
231
|
-
to_return(:body => '', :status => 404, :headers => { :content_type => "application/json; charset=utf-8"})
|
232
|
-
end
|
233
|
-
|
234
|
-
it "should fail to find resource" do
|
235
|
-
expect { github.orgs.delete_team team }.to raise_error(Github::ResourceNotFound)
|
236
|
-
end
|
237
|
-
end
|
238
|
-
end # delete_team
|
239
|
-
|
240
|
-
describe "team_members" do
|
241
|
-
context "resource found" do
|
242
|
-
before do
|
243
|
-
stub_get("/teams/#{team}/members").
|
244
|
-
to_return(:body => fixture('orgs/teams.json'), :status => 200, :headers => {:content_type => "application/json; charset=utf-8"})
|
245
|
-
end
|
246
|
-
|
247
|
-
it "should fail to get resource without org name" do
|
248
|
-
expect { github.orgs.team_members }.to raise_error(ArgumentError)
|
249
|
-
end
|
250
|
-
|
251
|
-
it "should get the resources" do
|
252
|
-
github.orgs.team_members team
|
253
|
-
a_get("/teams/#{team}/members").should have_been_made
|
254
|
-
end
|
255
|
-
|
256
|
-
it "should return array of resources" do
|
257
|
-
teams = github.orgs.team_members team
|
258
|
-
teams.should be_an Array
|
259
|
-
teams.should have(1).items
|
260
|
-
end
|
261
|
-
|
262
|
-
it "should be a mash type" do
|
263
|
-
teams = github.orgs.team_members team
|
264
|
-
teams.first.should be_a Hashie::Mash
|
265
|
-
end
|
266
|
-
|
267
|
-
it "should get team members information" do
|
268
|
-
teams = github.orgs.team_members team
|
269
|
-
teams.first.name.should == 'Owners'
|
270
|
-
end
|
271
|
-
|
272
|
-
it "should yield to a block" do
|
273
|
-
github.orgs.should_receive(:team_members).with(team).and_yield('web')
|
274
|
-
github.orgs.team_members(team) { |param| 'web' }
|
275
|
-
end
|
276
|
-
end
|
277
|
-
|
278
|
-
context "resource not found" do
|
279
|
-
before do
|
280
|
-
stub_get("/teams/#{team}/members").
|
281
|
-
to_return(:body => fixture('orgs/teams.json'), :status => 404, :headers => {:content_type => "application/json; charset=utf-8"})
|
282
|
-
end
|
283
|
-
|
284
|
-
it "should return 404 with a message 'Not Found'" do
|
285
|
-
expect {
|
286
|
-
github.orgs.team_members team
|
287
|
-
}.to raise_error(Github::ResourceNotFound)
|
288
|
-
end
|
289
|
-
end
|
290
|
-
end # team_members
|
291
|
-
|
292
|
-
describe "team_member?" do
|
293
|
-
context "with teamname ane membername passed" do
|
294
|
-
|
295
|
-
context "this repo is being watched by the user"
|
296
|
-
before do
|
297
|
-
github.oauth_token = nil
|
298
|
-
github.user = nil
|
299
|
-
stub_get("/teams/#{team}/members/#{member}").
|
300
|
-
to_return(:body => "", :status => 404, :headers => {:user_agent => github.user_agent})
|
301
|
-
end
|
302
|
-
|
303
|
-
it "should return false if resource not found" do
|
304
|
-
team_membership = github.orgs.team_member? team, member
|
305
|
-
team_membership.should be_false
|
306
|
-
end
|
307
|
-
|
308
|
-
it "should return true if resoure found" do
|
309
|
-
stub_get("/teams/#{team}/members/#{member}").
|
310
|
-
to_return(:body => "", :status => 204, :headers => {:user_agent => github.user_agent})
|
311
|
-
team_membership = github.orgs.team_member? team, member
|
312
|
-
team_membership.should be_true
|
313
|
-
end
|
314
|
-
|
315
|
-
end
|
316
|
-
|
317
|
-
context "without org name and member name passed" do
|
318
|
-
it "should fail validation " do
|
319
|
-
expect { github.orgs.team_member?(nil, nil) }.to raise_error(ArgumentError)
|
320
|
-
end
|
321
|
-
end
|
322
|
-
end # member?
|
323
|
-
|
324
|
-
describe "add_team_member" do
|
325
|
-
context "resouce added" do
|
326
|
-
before do
|
327
|
-
stub_put("/teams/#{team}/members/#{member}").
|
328
|
-
to_return(:body => '', :status => 204, :headers => {:content_type => "application/json; charset=utf-8"})
|
329
|
-
end
|
330
|
-
|
331
|
-
it "should fail to add resource if 'team' input is nil" do
|
332
|
-
expect {
|
333
|
-
github.orgs.add_team_member nil, member
|
334
|
-
}.to raise_error(ArgumentError)
|
335
|
-
end
|
336
|
-
|
337
|
-
it "should fail to add resource if 'member' input is nil" do
|
338
|
-
expect {
|
339
|
-
github.orgs.add_team_member team, nil
|
340
|
-
}.to raise_error(ArgumentError)
|
341
|
-
end
|
342
|
-
|
343
|
-
it "should add resource successfully" do
|
344
|
-
github.orgs.add_team_member team, member
|
345
|
-
a_put("/teams/#{team}/members/#{member}").should have_been_made
|
346
|
-
end
|
347
|
-
end
|
348
|
-
|
349
|
-
context "failed to add resource" do
|
350
|
-
before do
|
351
|
-
stub_put("/teams/#{team}/members/#{member}").
|
352
|
-
to_return(:body => '', :status => 404, :headers => {:content_type => "application/json; charset=utf-8"})
|
353
|
-
end
|
354
|
-
|
355
|
-
it "should fail to add resource" do
|
356
|
-
expect {
|
357
|
-
github.orgs.add_team_member team, member
|
358
|
-
}.to raise_error(Github::ResourceNotFound)
|
359
|
-
end
|
360
|
-
end
|
361
|
-
end # add_team_member
|
362
|
-
|
363
|
-
describe "remove_team_member" do
|
364
|
-
context "resouce deleted" do
|
365
|
-
before do
|
366
|
-
stub_delete("/teams/#{team}/members/#{member}").
|
367
|
-
to_return(:body => '', :status => 204, :headers => {:content_type => "application/json; charset=utf-8"})
|
368
|
-
end
|
369
|
-
|
370
|
-
it "should fail to delete resource if 'team' input is nil" do
|
371
|
-
expect {
|
372
|
-
github.orgs.remove_team_member nil, member
|
373
|
-
}.to raise_error(ArgumentError)
|
374
|
-
end
|
375
|
-
|
376
|
-
it "should fail to delete resource if 'member' input is nil" do
|
377
|
-
expect {
|
378
|
-
github.orgs.remove_team_member member, nil
|
379
|
-
}.to raise_error(ArgumentError)
|
380
|
-
end
|
381
|
-
|
382
|
-
it "should add resource successfully" do
|
383
|
-
github.orgs.remove_team_member team, member
|
384
|
-
a_delete("/teams/#{team}/members/#{member}").should have_been_made
|
385
|
-
end
|
386
|
-
end
|
387
|
-
|
388
|
-
context "failed to remove resource" do
|
389
|
-
before do
|
390
|
-
stub_delete("/teams/#{team}/members/#{member}").
|
391
|
-
to_return(:body => '', :status => 404, :headers => {:content_type => "application/json; charset=utf-8"})
|
392
|
-
end
|
393
|
-
|
394
|
-
it "should fail to remove resource" do
|
395
|
-
expect {
|
396
|
-
github.orgs.remove_team_member team, member
|
397
|
-
}.to raise_error(Github::ResourceNotFound)
|
398
|
-
end
|
399
|
-
end
|
400
|
-
end # remove_team_member
|
401
|
-
|
402
|
-
describe "team_repos" do
|
403
|
-
context "resource found" do
|
404
|
-
before do
|
405
|
-
stub_get("/teams/#{team}/repos").
|
406
|
-
to_return(:body => fixture('orgs/team_repos.json'), :status => 200, :headers => {:content_type => "application/json; charset=utf-8"})
|
407
|
-
end
|
408
|
-
|
409
|
-
it "should fail to get resource without team name" do
|
410
|
-
expect { github.orgs.team_repos nil }.to raise_error(ArgumentError)
|
411
|
-
end
|
412
|
-
|
413
|
-
it "should get the resources" do
|
414
|
-
github.orgs.team_repos team
|
415
|
-
a_get("/teams/#{team}/repos").should have_been_made
|
416
|
-
end
|
417
|
-
|
418
|
-
it "should return array of resources" do
|
419
|
-
team_repos = github.orgs.team_repos team
|
420
|
-
team_repos.should be_an Array
|
421
|
-
team_repos.should have(1).items
|
422
|
-
end
|
423
|
-
|
424
|
-
it "should be a mash type" do
|
425
|
-
team_repos = github.orgs.team_repos team
|
426
|
-
team_repos.first.should be_a Hashie::Mash
|
427
|
-
end
|
428
|
-
|
429
|
-
it "should get teams information" do
|
430
|
-
team_repos = github.orgs.team_repos team
|
431
|
-
team_repos.first.name.should == 'github'
|
432
|
-
end
|
433
|
-
|
434
|
-
it "should yield to a block" do
|
435
|
-
github.orgs.should_receive(:team_repos).with(team).and_yield('web')
|
436
|
-
github.orgs.team_repos(team) { |param| 'web' }
|
437
|
-
end
|
438
|
-
end
|
439
|
-
|
440
|
-
context "resource not found" do
|
441
|
-
before do
|
442
|
-
stub_get("/teams/#{team}/repos").
|
443
|
-
to_return(:body => '', :status => 404, :headers => {:content_type => "application/json; charset=utf-8"})
|
444
|
-
end
|
445
|
-
|
446
|
-
it "should return 404 with a message 'Not Found'" do
|
447
|
-
expect {
|
448
|
-
github.orgs.team_repos team
|
449
|
-
}.to raise_error(Github::ResourceNotFound)
|
450
|
-
end
|
451
|
-
end
|
452
|
-
end # team_repos
|
453
|
-
|
454
|
-
describe "team_repo?" do
|
455
|
-
context "with teamname, username ane reponame passed" do
|
456
|
-
|
457
|
-
context "this repo is managed by the team"
|
458
|
-
before do
|
459
|
-
github.oauth_token = nil
|
460
|
-
github.user = nil
|
461
|
-
stub_get("/teams/#{team}/repos/#{user}/#{repo}").
|
462
|
-
to_return(:body => "", :status => 404, :headers => {:user_agent => github.user_agent})
|
463
|
-
end
|
464
|
-
|
465
|
-
it "should return false if resource not found" do
|
466
|
-
team_managed = github.orgs.team_repo? team, user, repo
|
467
|
-
team_managed.should be_false
|
468
|
-
end
|
469
|
-
|
470
|
-
it "should return true if resoure found" do
|
471
|
-
stub_get("/teams/#{team}/repos/#{user}/#{repo}").
|
472
|
-
to_return(:body => "", :status => 204, :headers => {:user_agent => github.user_agent})
|
473
|
-
team_managed = github.orgs.team_repo? team, user, repo
|
474
|
-
team_managed.should be_true
|
475
|
-
end
|
476
|
-
end
|
477
|
-
|
478
|
-
context "without org name and member name passed" do
|
479
|
-
it "should fail validation " do
|
480
|
-
expect { github.orgs.team_repo?(nil, nil, nil) }.to raise_error(ArgumentError)
|
481
|
-
end
|
482
|
-
end
|
483
|
-
end # team_repo?
|
484
|
-
|
485
|
-
describe "add_team_repo" do
|
486
|
-
context "resouce added" do
|
487
|
-
before do
|
488
|
-
stub_put("/teams/#{team}/repos/#{user}/#{repo}").
|
489
|
-
to_return(:body => '', :status => 204, :headers => {:content_type => "application/json; charset=utf-8"})
|
490
|
-
end
|
491
|
-
|
492
|
-
it "should fail to add resource if 'team' input is nil" do
|
493
|
-
expect {
|
494
|
-
github.orgs.add_team_member nil, user, repo
|
495
|
-
}.to raise_error(ArgumentError)
|
496
|
-
end
|
497
|
-
|
498
|
-
it "should fail to add resource if 'user' input is nil" do
|
499
|
-
expect {
|
500
|
-
github.orgs.add_team_member team, nil, repo
|
501
|
-
}.to raise_error(ArgumentError)
|
502
|
-
end
|
503
|
-
|
504
|
-
it "should add resource successfully" do
|
505
|
-
github.orgs.add_team_repo team, user, repo
|
506
|
-
a_put("/teams/#{team}/repos/#{user}/#{repo}").should have_been_made
|
507
|
-
end
|
508
|
-
end
|
509
|
-
|
510
|
-
context "failed to add resource" do
|
511
|
-
before do
|
512
|
-
stub_put("/teams/#{team}/repos/#{user}/#{repo}").
|
513
|
-
to_return(:body => '', :status => 404, :headers => {:content_type => "application/json; charset=utf-8"})
|
514
|
-
end
|
515
|
-
|
516
|
-
it "should fail to add resource" do
|
517
|
-
expect {
|
518
|
-
github.orgs.add_team_repo team, user, repo
|
519
|
-
}.to raise_error(Github::ResourceNotFound)
|
520
|
-
end
|
521
|
-
end
|
522
|
-
end # add_team_repo
|
523
|
-
|
524
|
-
describe "remove_team_member" do
|
525
|
-
context "resouce deleted" do
|
526
|
-
before do
|
527
|
-
stub_delete("/teams/#{team}/repos/#{user}/#{repo}").
|
528
|
-
to_return(:body => '', :status => 204, :headers => {:content_type => "application/json; charset=utf-8"})
|
529
|
-
end
|
530
|
-
|
531
|
-
it "should fail to delete resource if 'team' input is nil" do
|
532
|
-
expect {
|
533
|
-
github.orgs.remove_team_repo nil, user, repo
|
534
|
-
}.to raise_error(ArgumentError)
|
535
|
-
end
|
536
|
-
|
537
|
-
it "should fail to delete resource if 'user' input is nil" do
|
538
|
-
expect {
|
539
|
-
github.orgs.remove_team_repo team, nil, repo
|
540
|
-
}.to raise_error(ArgumentError)
|
541
|
-
end
|
542
|
-
|
543
|
-
it "should add resource successfully" do
|
544
|
-
github.orgs.remove_team_repo team, user, repo
|
545
|
-
a_delete("/teams/#{team}/repos/#{user}/#{repo}").should have_been_made
|
546
|
-
end
|
547
|
-
end
|
548
|
-
|
549
|
-
context "failed to remove resource" do
|
550
|
-
before do
|
551
|
-
stub_delete("/teams/#{team}/repos/#{user}/#{repo}").
|
552
|
-
to_return(:body => '', :status => 404, :headers => {:content_type => "application/json; charset=utf-8"})
|
553
|
-
end
|
554
|
-
|
555
|
-
it "should fail to remove resource" do
|
556
|
-
expect {
|
557
|
-
github.orgs.remove_team_repo team, user, repo
|
558
|
-
}.to raise_error(Github::ResourceNotFound)
|
559
|
-
end
|
560
|
-
end
|
561
|
-
end # remove_team_repo
|
562
|
-
|
563
|
-
end # Github::Orgs::Teams
|