gitlab 3.0.0 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -0
  3. data/.travis.yml +1 -0
  4. data/LICENSE.txt +1 -1
  5. data/README.md +28 -3
  6. data/bin/gitlab +7 -0
  7. data/gitlab.gemspec +3 -2
  8. data/lib/gitlab.rb +8 -0
  9. data/lib/gitlab/api.rb +1 -1
  10. data/lib/gitlab/cli.rb +57 -0
  11. data/lib/gitlab/cli_helpers.rb +141 -0
  12. data/lib/gitlab/client.rb +8 -6
  13. data/lib/gitlab/client/branches.rb +79 -0
  14. data/lib/gitlab/client/merge_requests.rb +15 -2
  15. data/lib/gitlab/client/projects.rb +25 -4
  16. data/lib/gitlab/client/repositories.rb +22 -23
  17. data/lib/gitlab/client/system_hooks.rb +58 -0
  18. data/lib/gitlab/client/users.rb +17 -0
  19. data/lib/gitlab/configuration.rb +3 -3
  20. data/lib/gitlab/objectified_hash.rb +8 -2
  21. data/lib/gitlab/request.rb +21 -5
  22. data/lib/gitlab/version.rb +1 -1
  23. data/spec/fixtures/branch.json +1 -0
  24. data/spec/fixtures/{project_branches.json → branches.json} +0 -0
  25. data/spec/fixtures/create_branch.json +1 -0
  26. data/spec/fixtures/merge_request_comments.json +1 -0
  27. data/spec/fixtures/project_commit.json +13 -0
  28. data/spec/fixtures/project_commit_diff.json +10 -0
  29. data/spec/fixtures/{project_branch.json → protect_branch.json} +1 -1
  30. data/spec/fixtures/system_hook.json +1 -0
  31. data/spec/fixtures/system_hook_test.json +1 -0
  32. data/spec/fixtures/system_hooks.json +1 -0
  33. data/spec/fixtures/unprotect_branch.json +1 -0
  34. data/spec/gitlab/cli_spec.rb +80 -0
  35. data/spec/gitlab/client/branches_spec.rb +103 -0
  36. data/spec/gitlab/client/groups_spec.rb +21 -21
  37. data/spec/gitlab/client/issues_spec.rb +26 -26
  38. data/spec/gitlab/client/merge_requests_spec.rb +45 -13
  39. data/spec/gitlab/client/milestones_spec.rb +11 -11
  40. data/spec/gitlab/client/notes_spec.rb +30 -30
  41. data/spec/gitlab/client/projects_spec.rb +93 -59
  42. data/spec/gitlab/client/repositories_spec.rb +28 -25
  43. data/spec/gitlab/client/snippets_spec.rb +16 -16
  44. data/spec/gitlab/client/system_hooks_spec.rb +69 -0
  45. data/spec/gitlab/client/users_spec.rb +60 -24
  46. data/spec/gitlab/objectified_hash_spec.rb +23 -0
  47. data/spec/gitlab/request_spec.rb +48 -0
  48. data/spec/gitlab_spec.rb +16 -7
  49. data/spec/spec_helper.rb +19 -8
  50. metadata +70 -22
@@ -9,12 +9,12 @@ describe Gitlab::Client do
9
9
  end
10
10
 
11
11
  it "should get the correct resource" do
12
- a_get("/projects/3/notes").should have_been_made
12
+ expect(a_get("/projects/3/notes")).to have_been_made
13
13
  end
14
14
 
15
15
  it "should return an array of notes" do
16
- @notes.should be_an Array
17
- @notes.first.author.name.should == "John Smith"
16
+ expect(@notes).to be_an Array
17
+ expect(@notes.first.author.name).to eq("John Smith")
18
18
  end
19
19
  end
20
20
 
@@ -25,12 +25,12 @@ describe Gitlab::Client do
25
25
  end
26
26
 
27
27
  it "should get the correct resource" do
28
- a_get("/projects/3/issues/7/notes").should have_been_made
28
+ expect(a_get("/projects/3/issues/7/notes")).to have_been_made
29
29
  end
30
30
 
31
31
  it "should return an array of notes" do
32
- @notes.should be_an Array
33
- @notes.first.author.name.should == "John Smith"
32
+ expect(@notes).to be_an Array
33
+ expect(@notes.first.author.name).to eq("John Smith")
34
34
  end
35
35
  end
36
36
 
@@ -41,12 +41,12 @@ describe Gitlab::Client do
41
41
  end
42
42
 
43
43
  it "should get the correct resource" do
44
- a_get("/projects/3/snippets/7/notes").should have_been_made
44
+ expect(a_get("/projects/3/snippets/7/notes")).to have_been_made
45
45
  end
46
46
 
47
47
  it "should return an array of notes" do
48
- @notes.should be_an Array
49
- @notes.first.author.name.should == "John Smith"
48
+ expect(@notes).to be_an Array
49
+ expect(@notes.first.author.name).to eq("John Smith")
50
50
  end
51
51
  end
52
52
  end
@@ -59,12 +59,12 @@ describe Gitlab::Client do
59
59
  end
60
60
 
61
61
  it "should get the correct resource" do
62
- a_get("/projects/3/notes/1201").should have_been_made
62
+ expect(a_get("/projects/3/notes/1201")).to have_been_made
63
63
  end
64
64
 
65
65
  it "should return information about a note" do
66
- @note.body.should == "The solution is rather tricky"
67
- @note.author.name.should == "John Smith"
66
+ expect(@note.body).to eq("The solution is rather tricky")
67
+ expect(@note.author.name).to eq("John Smith")
68
68
  end
69
69
  end
70
70
 
@@ -75,12 +75,12 @@ describe Gitlab::Client do
75
75
  end
76
76
 
77
77
  it "should get the correct resource" do
78
- a_get("/projects/3/issues/7/notes/1201").should have_been_made
78
+ expect(a_get("/projects/3/issues/7/notes/1201")).to have_been_made
79
79
  end
80
80
 
81
81
  it "should return information about a note" do
82
- @note.body.should == "The solution is rather tricky"
83
- @note.author.name.should == "John Smith"
82
+ expect(@note.body).to eq("The solution is rather tricky")
83
+ expect(@note.author.name).to eq("John Smith")
84
84
  end
85
85
  end
86
86
 
@@ -91,12 +91,12 @@ describe Gitlab::Client do
91
91
  end
92
92
 
93
93
  it "should get the correct resource" do
94
- a_get("/projects/3/snippets/7/notes/1201").should have_been_made
94
+ expect(a_get("/projects/3/snippets/7/notes/1201")).to have_been_made
95
95
  end
96
96
 
97
97
  it "should return information about a note" do
98
- @note.body.should == "The solution is rather tricky"
99
- @note.author.name.should == "John Smith"
98
+ expect(@note.body).to eq("The solution is rather tricky")
99
+ expect(@note.author.name).to eq("John Smith")
100
100
  end
101
101
  end
102
102
  end
@@ -109,13 +109,13 @@ describe Gitlab::Client do
109
109
  end
110
110
 
111
111
  it "should get the correct resource" do
112
- a_post("/projects/3/notes").
113
- with(:body => {:body => 'The solution is rather tricky'}).should have_been_made
112
+ expect(a_post("/projects/3/notes").
113
+ with(:body => {:body => 'The solution is rather tricky'})).to have_been_made
114
114
  end
115
115
 
116
116
  it "should return information about a created note" do
117
- @note.body.should == "The solution is rather tricky"
118
- @note.author.name.should == "John Smith"
117
+ expect(@note.body).to eq("The solution is rather tricky")
118
+ expect(@note.author.name).to eq("John Smith")
119
119
  end
120
120
  end
121
121
 
@@ -126,13 +126,13 @@ describe Gitlab::Client do
126
126
  end
127
127
 
128
128
  it "should get the correct resource" do
129
- a_post("/projects/3/issues/7/notes").
130
- with(:body => {:body => 'The solution is rather tricky'}).should have_been_made
129
+ expect(a_post("/projects/3/issues/7/notes").
130
+ with(:body => {:body => 'The solution is rather tricky'})).to have_been_made
131
131
  end
132
132
 
133
133
  it "should return information about a created note" do
134
- @note.body.should == "The solution is rather tricky"
135
- @note.author.name.should == "John Smith"
134
+ expect(@note.body).to eq("The solution is rather tricky")
135
+ expect(@note.author.name).to eq("John Smith")
136
136
  end
137
137
  end
138
138
 
@@ -143,13 +143,13 @@ describe Gitlab::Client do
143
143
  end
144
144
 
145
145
  it "should get the correct resource" do
146
- a_post("/projects/3/snippets/7/notes").
147
- with(:body => {:body => 'The solution is rather tricky'}).should have_been_made
146
+ expect(a_post("/projects/3/snippets/7/notes").
147
+ with(:body => {:body => 'The solution is rather tricky'})).to have_been_made
148
148
  end
149
149
 
150
150
  it "should return information about a created note" do
151
- @note.body.should == "The solution is rather tricky"
152
- @note.author.name.should == "John Smith"
151
+ expect(@note.body).to eq("The solution is rather tricky")
152
+ expect(@note.author.name).to eq("John Smith")
153
153
  end
154
154
  end
155
155
  end
@@ -8,13 +8,13 @@ describe Gitlab::Client do
8
8
  end
9
9
 
10
10
  it "should get the correct resource" do
11
- a_get("/projects").should have_been_made
11
+ expect(a_get("/projects")).to have_been_made
12
12
  end
13
13
 
14
14
  it "should return an array of projects" do
15
- @projects.should be_an Array
16
- @projects.first.name.should == "Brute"
17
- @projects.first.owner.name.should == "John Smith"
15
+ expect(@projects).to be_an Array
16
+ expect(@projects.first.name).to eq("Brute")
17
+ expect(@projects.first.owner.name).to eq("John Smith")
18
18
  end
19
19
  end
20
20
 
@@ -25,12 +25,12 @@ describe Gitlab::Client do
25
25
  end
26
26
 
27
27
  it "should get the correct resource" do
28
- a_get("/projects/3").should have_been_made
28
+ expect(a_get("/projects/3")).to have_been_made
29
29
  end
30
30
 
31
31
  it "should return information about a project" do
32
- @project.name.should == "Gitlab"
33
- @project.owner.name.should == "John Smith"
32
+ expect(@project.name).to eq("Gitlab")
33
+ expect(@project.owner.name).to eq("John Smith")
34
34
  end
35
35
  end
36
36
 
@@ -41,12 +41,12 @@ describe Gitlab::Client do
41
41
  end
42
42
 
43
43
  it "should get the correct resource" do
44
- a_post("/projects").should have_been_made
44
+ expect(a_post("/projects")).to have_been_made
45
45
  end
46
46
 
47
47
  it "should return information about a created project" do
48
- @project.name.should == "Gitlab"
49
- @project.owner.name.should == "John Smith"
48
+ expect(@project.name).to eq("Gitlab")
49
+ expect(@project.owner.name).to eq("John Smith")
50
50
  end
51
51
  end
52
52
 
@@ -59,8 +59,24 @@ describe Gitlab::Client do
59
59
  end
60
60
 
61
61
  it "should return information about a created project" do
62
- @project.name.should == "Brute"
63
- @project.owner.name.should == "John Owner"
62
+ expect(@project.name).to eq("Brute")
63
+ expect(@project.owner.name).to eq("John Owner")
64
+ end
65
+ end
66
+
67
+ describe ".delete_project" do
68
+ before do
69
+ stub_delete("/projects/Gitlab", "project")
70
+ @project = Gitlab.delete_project('Gitlab')
71
+ end
72
+
73
+ it "should get the correct resource" do
74
+ expect(a_delete("/projects/Gitlab")).to have_been_made
75
+ end
76
+
77
+ it "should return information about a deleted project" do
78
+ expect(@project.name).to eq("Gitlab")
79
+ expect(@project.owner.name).to eq("John Smith")
64
80
  end
65
81
  end
66
82
 
@@ -71,12 +87,12 @@ describe Gitlab::Client do
71
87
  end
72
88
 
73
89
  it "should get the correct resource" do
74
- a_get("/projects/3/members").should have_been_made
90
+ expect(a_get("/projects/3/members")).to have_been_made
75
91
  end
76
92
 
77
93
  it "should return an array of team members" do
78
- @team_members.should be_an Array
79
- @team_members.first.name.should == "John Smith"
94
+ expect(@team_members).to be_an Array
95
+ expect(@team_members.first.name).to eq("John Smith")
80
96
  end
81
97
  end
82
98
 
@@ -87,11 +103,11 @@ describe Gitlab::Client do
87
103
  end
88
104
 
89
105
  it "should get the correct resource" do
90
- a_get("/projects/3/members/1").should have_been_made
106
+ expect(a_get("/projects/3/members/1")).to have_been_made
91
107
  end
92
108
 
93
109
  it "should return information about a team member" do
94
- @team_member.name.should == "John Smith"
110
+ expect(@team_member.name).to eq("John Smith")
95
111
  end
96
112
  end
97
113
 
@@ -102,12 +118,12 @@ describe Gitlab::Client do
102
118
  end
103
119
 
104
120
  it "should get the correct resource" do
105
- a_post("/projects/3/members").
106
- with(:body => {:user_id => '1', :access_level => '40'}).should have_been_made
121
+ expect(a_post("/projects/3/members").
122
+ with(:body => {:user_id => '1', :access_level => '40'})).to have_been_made
107
123
  end
108
124
 
109
125
  it "should return information about an added team member" do
110
- @team_member.name.should == "John Smith"
126
+ expect(@team_member.name).to eq("John Smith")
111
127
  end
112
128
  end
113
129
 
@@ -118,12 +134,12 @@ describe Gitlab::Client do
118
134
  end
119
135
 
120
136
  it "should get the correct resource" do
121
- a_put("/projects/3/members/1").
122
- with(:body => {:access_level => '40'}).should have_been_made
137
+ expect(a_put("/projects/3/members/1").
138
+ with(:body => {:access_level => '40'})).to have_been_made
123
139
  end
124
140
 
125
141
  it "should return information about an edited team member" do
126
- @team_member.name.should == "John Smith"
142
+ expect(@team_member.name).to eq("John Smith")
127
143
  end
128
144
  end
129
145
 
@@ -134,11 +150,11 @@ describe Gitlab::Client do
134
150
  end
135
151
 
136
152
  it "should get the correct resource" do
137
- a_delete("/projects/3/members/1").should have_been_made
153
+ expect(a_delete("/projects/3/members/1")).to have_been_made
138
154
  end
139
155
 
140
156
  it "should return information about a removed team member" do
141
- @team_member.name.should == "John Smith"
157
+ expect(@team_member.name).to eq("John Smith")
142
158
  end
143
159
  end
144
160
 
@@ -149,12 +165,12 @@ describe Gitlab::Client do
149
165
  end
150
166
 
151
167
  it "should get the correct resource" do
152
- a_get("/projects/1/hooks").should have_been_made
168
+ expect(a_get("/projects/1/hooks")).to have_been_made
153
169
  end
154
170
 
155
171
  it "should return an array of hooks" do
156
- @hooks.should be_an Array
157
- @hooks.first.url.should == "https://api.example.net/v1/webhooks/ci"
172
+ expect(@hooks).to be_an Array
173
+ expect(@hooks.first.url).to eq("https://api.example.net/v1/webhooks/ci")
158
174
  end
159
175
  end
160
176
 
@@ -165,27 +181,45 @@ describe Gitlab::Client do
165
181
  end
166
182
 
167
183
  it "should get the correct resource" do
168
- a_get("/projects/1/hooks/1").should have_been_made
184
+ expect(a_get("/projects/1/hooks/1")).to have_been_made
169
185
  end
170
186
 
171
187
  it "should return information about a hook" do
172
- @hook.url.should == "https://api.example.net/v1/webhooks/ci"
188
+ expect(@hook.url).to eq("https://api.example.net/v1/webhooks/ci")
173
189
  end
174
190
  end
175
191
 
176
192
  describe ".add_project_hook" do
177
- before do
178
- stub_post("/projects/1/hooks", "project_hook")
179
- @hook = Gitlab.add_project_hook(1, "https://api.example.net/v1/webhooks/ci")
180
- end
193
+ context "without specified events" do
194
+ before do
195
+ stub_post("/projects/1/hooks", "project_hook")
196
+ @hook = Gitlab.add_project_hook(1, "https://api.example.net/v1/webhooks/ci")
197
+ end
181
198
 
182
- it "should get the correct resource" do
183
- body = {:url => "https://api.example.net/v1/webhooks/ci"}
184
- a_post("/projects/1/hooks").with(:body => body).should have_been_made
199
+ it "should get the correct resource" do
200
+ body = {:url => "https://api.example.net/v1/webhooks/ci"}
201
+ expect(a_post("/projects/1/hooks").with(:body => body)).to have_been_made
202
+ end
203
+
204
+ it "should return information about an added hook" do
205
+ expect(@hook.url).to eq("https://api.example.net/v1/webhooks/ci")
206
+ end
185
207
  end
186
208
 
187
- it "should return information about an added hook" do
188
- @hook.url.should == "https://api.example.net/v1/webhooks/ci"
209
+ context "with specified events" do
210
+ before do
211
+ stub_post("/projects/1/hooks", "project_hook")
212
+ @hook = Gitlab.add_project_hook(1, "https://api.example.net/v1/webhooks/ci", push_events: true, merge_requests_events: true)
213
+ end
214
+
215
+ it "should get the correct resource" do
216
+ body = {:url => "https://api.example.net/v1/webhooks/ci", push_events: "true", merge_requests_events: "true"}
217
+ expect(a_post("/projects/1/hooks").with(:body => body)).to have_been_made
218
+ end
219
+
220
+ it "should return information about an added hook" do
221
+ expect(@hook.url).to eq("https://api.example.net/v1/webhooks/ci")
222
+ end
189
223
  end
190
224
  end
191
225
 
@@ -197,11 +231,11 @@ describe Gitlab::Client do
197
231
 
198
232
  it "should get the correct resource" do
199
233
  body = {:url => "https://api.example.net/v1/webhooks/ci"}
200
- a_put("/projects/1/hooks/1").with(:body => body).should have_been_made
234
+ expect(a_put("/projects/1/hooks/1").with(:body => body)).to have_been_made
201
235
  end
202
236
 
203
237
  it "should return information about an edited hook" do
204
- @hook.url.should == "https://api.example.net/v1/webhooks/ci"
238
+ expect(@hook.url).to eq("https://api.example.net/v1/webhooks/ci")
205
239
  end
206
240
  end
207
241
 
@@ -212,11 +246,11 @@ describe Gitlab::Client do
212
246
  end
213
247
 
214
248
  it "should get the correct resource" do
215
- a_delete("/projects/1/hooks/1").should have_been_made
249
+ expect(a_delete("/projects/1/hooks/1")).to have_been_made
216
250
  end
217
251
 
218
252
  it "should return information about a deleted hook" do
219
- @hook.url.should == "https://api.example.net/v1/webhooks/ci"
253
+ expect(@hook.url).to eq("https://api.example.net/v1/webhooks/ci")
220
254
  end
221
255
  end
222
256
 
@@ -227,12 +261,12 @@ describe Gitlab::Client do
227
261
  end
228
262
 
229
263
  it "should get the correct resource" do
230
- a_post("/projects/42/fork/24").should have_been_made
264
+ expect(a_post("/projects/42/fork/24")).to have_been_made
231
265
  end
232
266
 
233
267
  it "should return information about a forked project" do
234
- @forked_project_link.forked_from_project_id.should == 24
235
- @forked_project_link.forked_to_project_id.should == 42
268
+ expect(@forked_project_link.forked_from_project_id).to eq(24)
269
+ expect(@forked_project_link.forked_to_project_id).to eq(42)
236
270
  end
237
271
  end
238
272
 
@@ -243,11 +277,11 @@ describe Gitlab::Client do
243
277
  end
244
278
 
245
279
  it "should be sent to correct resource" do
246
- a_delete("/projects/42/fork").should have_been_made
280
+ expect(a_delete("/projects/42/fork")).to have_been_made
247
281
  end
248
282
 
249
283
  it "should return information about an unforked project" do
250
- @forked_project_link.forked_to_project_id.should == 42
284
+ expect(@forked_project_link.forked_to_project_id).to eq(42)
251
285
  end
252
286
  end
253
287
 
@@ -258,14 +292,14 @@ describe Gitlab::Client do
258
292
  end
259
293
 
260
294
  it "should get the correct resource" do
261
- a_get("/projects/42/keys").should have_been_made
295
+ expect(a_get("/projects/42/keys")).to have_been_made
262
296
  end
263
297
 
264
298
  it "should return project deploy keys" do
265
- @deploy_keys.should be_an Array
266
- @deploy_keys.first.id.should eq 2
267
- @deploy_keys.first.title.should eq "Key Title"
268
- @deploy_keys.first.key.should match(/ssh-rsa/)
299
+ expect(@deploy_keys).to be_an Array
300
+ expect(@deploy_keys.first.id).to eq 2
301
+ expect(@deploy_keys.first.title).to eq "Key Title"
302
+ expect(@deploy_keys.first.key).to match(/ssh-rsa/)
269
303
  end
270
304
  end
271
305
 
@@ -276,13 +310,13 @@ describe Gitlab::Client do
276
310
  end
277
311
 
278
312
  it "should get the correct resource" do
279
- a_get("/projects/42/keys/2").should have_been_made
313
+ expect(a_get("/projects/42/keys/2")).to have_been_made
280
314
  end
281
315
 
282
316
  it "should return project deploy key" do
283
- @deploy_key.id.should eq 2
284
- @deploy_key.title.should eq "Key Title"
285
- @deploy_key.key.should match(/ssh-rsa/)
317
+ expect(@deploy_key.id).to eq 2
318
+ expect(@deploy_key.title).to eq "Key Title"
319
+ expect(@deploy_key.key).to match(/ssh-rsa/)
286
320
  end
287
321
  end
288
322
 
@@ -293,11 +327,11 @@ describe Gitlab::Client do
293
327
  end
294
328
 
295
329
  it "should get the correct resource" do
296
- a_delete("/projects/42/keys/2").should have_been_made
330
+ expect(a_delete("/projects/42/keys/2")).to have_been_made
297
331
  end
298
332
 
299
333
  it "should return information about a deleted key" do
300
- @deploy_key.id.should == 2
334
+ expect(@deploy_key.id).to eq(2)
301
335
  end
302
336
  end
303
337
  end