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