gitlab 4.1.0 → 4.2.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 (46) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +17 -0
  3. data/lib/gitlab/client.rb +4 -0
  4. data/lib/gitlab/client/award_emojis.rb +135 -0
  5. data/lib/gitlab/client/boards.rb +88 -0
  6. data/lib/gitlab/client/branches.rb +12 -7
  7. data/lib/gitlab/client/commits.rb +6 -6
  8. data/lib/gitlab/client/environments.rb +87 -0
  9. data/lib/gitlab/client/labels.rb +33 -4
  10. data/lib/gitlab/client/merge_requests.rb +0 -59
  11. data/lib/gitlab/client/notes.rb +106 -0
  12. data/lib/gitlab/client/projects.rb +48 -44
  13. data/lib/gitlab/client/repository_files.rb +32 -26
  14. data/lib/gitlab/client/system_hooks.rb +5 -2
  15. data/lib/gitlab/client/todos.rb +44 -0
  16. data/lib/gitlab/version.rb +1 -1
  17. data/spec/fixtures/board_list.json +1 -0
  18. data/spec/fixtures/board_lists.json +1 -0
  19. data/spec/fixtures/boards.json +1 -0
  20. data/spec/fixtures/environment.json +6 -0
  21. data/spec/fixtures/environments.json +14 -0
  22. data/spec/fixtures/issue_award_emoji.json +16 -0
  23. data/spec/fixtures/issue_award_emojis.json +34 -0
  24. data/spec/fixtures/label.json +1 -1
  25. data/spec/fixtures/label_unsubscribe.json +1 -0
  26. data/spec/fixtures/merge_request_award_emoji.json +16 -0
  27. data/spec/fixtures/merge_request_award_emojis.json +34 -0
  28. data/spec/fixtures/note_award_emoji.json +16 -0
  29. data/spec/fixtures/note_award_emojis.json +18 -0
  30. data/spec/fixtures/snippet_award_emoji.json +16 -0
  31. data/spec/fixtures/snippet_award_emojis.json +34 -0
  32. data/spec/fixtures/todo.json +73 -0
  33. data/spec/fixtures/todos.json +148 -0
  34. data/spec/gitlab/client/award_emojis_spec.rb +391 -0
  35. data/spec/gitlab/client/boards_spec.rb +94 -0
  36. data/spec/gitlab/client/branches_spec.rb +22 -5
  37. data/spec/gitlab/client/commits_spec.rb +2 -2
  38. data/spec/gitlab/client/environments_spec.rb +132 -0
  39. data/spec/gitlab/client/groups_spec.rb +10 -12
  40. data/spec/gitlab/client/labels_spec.rb +32 -0
  41. data/spec/gitlab/client/notes_spec.rb +128 -0
  42. data/spec/gitlab/client/projects_spec.rb +20 -10
  43. data/spec/gitlab/client/repository_files_spec.rb +30 -12
  44. data/spec/gitlab/client/system_hooks_spec.rb +2 -2
  45. data/spec/gitlab/client/todos_spec.rb +45 -0
  46. metadata +46 -2
@@ -0,0 +1,94 @@
1
+ require 'spec_helper'
2
+
3
+ describe Gitlab::Client do
4
+ describe ".boards" do
5
+ before do
6
+ stub_get("/projects/3/boards", "boards")
7
+ @boards = Gitlab.boards(3)
8
+ end
9
+
10
+ it "should get the correct resource" do
11
+ expect(a_get("/projects/3/boards")).to have_been_made
12
+ end
13
+
14
+ it "should return a paginated response of project's boards" do
15
+ expect(@boards).to be_a Gitlab::PaginatedResponse
16
+ end
17
+ end
18
+
19
+ describe ".board_lists" do
20
+ before do
21
+ stub_get("/projects/3/boards/1/lists", "board_lists")
22
+ @board_lists = Gitlab.board_lists(3, 1)
23
+ end
24
+
25
+ it "should get the correct resource" do
26
+ expect(a_get("/projects/3/boards/1/lists")).to have_been_made
27
+ end
28
+
29
+ it "should return a paginated response of board's lists" do
30
+ expect(@board_lists).to be_a Gitlab::PaginatedResponse
31
+ expect(@board_lists.first.id).to eq(1)
32
+ end
33
+ end
34
+
35
+ describe ".board_list" do
36
+ before do
37
+ stub_get("/projects/3/boards/1/lists/1", "board_list")
38
+ @board_list = Gitlab.board_list(3, 1, 1)
39
+ end
40
+
41
+ it "should get the correct resource" do
42
+ expect(a_get("/projects/3/boards/1/lists/1")).to have_been_made
43
+ end
44
+
45
+ it "should return information about the list" do
46
+ expect(@board_list.id).to eq(1)
47
+ end
48
+ end
49
+
50
+ describe ".create_board_list" do
51
+ before do
52
+ stub_post("/projects/3/boards/1/lists", "board_list")
53
+ @board_list = Gitlab.create_board_list(3, 1, 4)
54
+ end
55
+
56
+ it "should get the correct resource" do
57
+ expect(a_post("/projects/3/boards/1/lists")).to have_been_made
58
+ end
59
+
60
+ it "should return information about a created board" do
61
+ expect(@board_list.position).to eq(1)
62
+ end
63
+ end
64
+
65
+ describe ".edit_board_list" do
66
+ before do
67
+ stub_put("/projects/3/boards/1/lists/1", "board_list")
68
+ @board_list = Gitlab.edit_board_list(3, 1, 1, 3)
69
+ end
70
+
71
+ it "should get the correct resource" do
72
+ expect(a_put("/projects/3/boards/1/lists/1")).to have_been_made
73
+ end
74
+
75
+ it "should return information about an edited board" do
76
+ expect(@board_list.id).to eq(1)
77
+ end
78
+ end
79
+
80
+ describe ".delete_board_list" do
81
+ before do
82
+ stub_delete("/projects/3/boards/1/lists/1", "board_list")
83
+ @board_list = Gitlab.delete_board_list(3, 1, 1)
84
+ end
85
+
86
+ it "should get the correct resource" do
87
+ expect(a_delete("/projects/3/boards/1/lists/1")).to have_been_made
88
+ end
89
+
90
+ it "should return information about the deleted board list" do
91
+ expect(@board_list.id).to eq(1)
92
+ end
93
+ end
94
+ end
@@ -40,15 +40,32 @@ describe Gitlab::Client do
40
40
  describe ".protect_branch" do
41
41
  before do
42
42
  stub_put("/projects/3/repository/branches/api/protect", "branch")
43
- @branch = Gitlab.protect_branch(3, "api")
44
43
  end
45
44
 
46
- it "should get the correct resource" do
47
- expect(a_put("/projects/3/repository/branches/api/protect")).to have_been_made
45
+ context "without options" do
46
+ before do
47
+ @branch = Gitlab.protect_branch(3, "api")
48
+ end
49
+
50
+ it "should update the correct resource" do
51
+ expect(a_put("/projects/3/repository/branches/api/protect")).to have_been_made
52
+ end
53
+
54
+ it "should return information about a protected repository branch" do
55
+ expect(@branch.name).to eq("api")
56
+ end
48
57
  end
49
58
 
50
- it "should return information about a protected repository branch" do
51
- expect(@branch.name).to eq("api")
59
+ context "with options" do
60
+ before do
61
+ @branch = Gitlab.protect_branch(3, "api", developers_can_push: true)
62
+ end
63
+
64
+ it "should update the correct resource with the correct options" do
65
+ expect(
66
+ a_put("/projects/3/repository/branches/api/protect").with(body: { developers_can_push: 'true' })
67
+ ).to have_been_made
68
+ end
52
69
  end
53
70
  end
54
71
 
@@ -148,7 +148,7 @@ describe Gitlab::Client do
148
148
 
149
149
  let(:query) do
150
150
  {
151
- branch_name: 'dev',
151
+ branch: 'dev',
152
152
  commit_message: 'refactors everything',
153
153
  actions: actions,
154
154
  author_email: 'joe@sample.org',
@@ -157,7 +157,7 @@ describe Gitlab::Client do
157
157
  end
158
158
 
159
159
  before do
160
- stub_post("/projects/6/repository/commits", 'project_commit_create').with(query: query)
160
+ stub_post("/projects/6/repository/commits", 'project_commit_create').with(body: query)
161
161
  @commit = Gitlab.create_commit(6, 'dev', 'refactors everything', actions, {author_email: 'joe@sample.org', author_name: 'Joe Sample'})
162
162
  end
163
163
 
@@ -0,0 +1,132 @@
1
+ require 'spec_helper'
2
+
3
+ describe Gitlab::Client do
4
+ describe ".environments" do
5
+ before do
6
+ stub_get("/projects/3/environments", "environments")
7
+ @environments = Gitlab.environments(3)
8
+ end
9
+
10
+ it "should get the correct resource" do
11
+ expect(a_get("/projects/3/environments")).to have_been_made
12
+ end
13
+
14
+ it "should return a paginated response of project's environments" do
15
+ expect(@environments).to be_a Gitlab::PaginatedResponse
16
+ end
17
+ end
18
+
19
+ describe ".environment" do
20
+ before do
21
+ stub_get("/projects/3/environments/12", "environment")
22
+ @environment = Gitlab.environment(3, 12)
23
+ end
24
+
25
+ it "should get the correct resource" do
26
+ expect(a_get("/projects/3/environments/12")).to have_been_made
27
+ end
28
+
29
+ it "should return a single environment" do
30
+ expect(@environment).to be_a Gitlab::ObjectifiedHash
31
+ end
32
+
33
+ it "should return information about an environment" do
34
+ expect(@environment.id).to eq(12)
35
+ expect(@environment.name).to eq("staging")
36
+ end
37
+ end
38
+
39
+ describe ".create_environment" do
40
+ context "without external_url" do
41
+ before do
42
+ stub_post("/projects/3/environments", "environment")
43
+ @environment = Gitlab.create_environment(3, 'staging')
44
+ end
45
+
46
+ it "should get the correct resource" do
47
+ expect(a_post("/projects/3/environments").with(body: { name: 'staging' })).to have_been_made
48
+ end
49
+
50
+ it "should return a single environment" do
51
+ expect(@environment).to be_a Gitlab::ObjectifiedHash
52
+ end
53
+
54
+ it "should return information about an environment" do
55
+ expect(@environment.name).to eq("staging")
56
+ end
57
+ end
58
+
59
+ context "with external_url" do
60
+ before do
61
+ stub_post("/projects/3/environments", "environment")
62
+ @environment = Gitlab.create_environment(3, 'staging', external_url: "https://staging.example.gitlab.com")
63
+ end
64
+
65
+ it "should get the correct resource" do
66
+ expect(a_post("/projects/3/environments")
67
+ .with(body: { name: 'staging', external_url: "https://staging.example.gitlab.com" })).to have_been_made
68
+ end
69
+ end
70
+ end
71
+
72
+ describe ".edit_environment" do
73
+ before do
74
+ stub_put("/projects/3/environments/12", "environment")
75
+ @environment = Gitlab.edit_environment(3, 12, {
76
+ name: 'staging',
77
+ external_url: "https://staging.example.gitlab.com"
78
+ })
79
+ end
80
+
81
+ it "should get the correct resource" do
82
+ expect(a_put("/projects/3/environments/12")
83
+ .with(body: { name: 'staging', external_url: "https://staging.example.gitlab.com" })).to have_been_made
84
+ end
85
+
86
+ it "should return a single environment" do
87
+ expect(@environment).to be_a Gitlab::ObjectifiedHash
88
+ end
89
+
90
+ it "should return information about an environment" do
91
+ expect(@environment.name).to eq("staging")
92
+ end
93
+ end
94
+
95
+ describe ".delete_environment" do
96
+ before do
97
+ stub_delete("/projects/3/environments/12", "environment")
98
+ @environment = Gitlab.delete_environment(3, 12)
99
+ end
100
+
101
+ it "should get the correct resource" do
102
+ expect(a_delete("/projects/3/environments/12")).to have_been_made
103
+ end
104
+
105
+ it "should return a single pipeline" do
106
+ expect(@environment).to be_a Gitlab::ObjectifiedHash
107
+ end
108
+
109
+ it "should return information about a pipeline" do
110
+ expect(@environment.name).to eq("staging")
111
+ end
112
+ end
113
+
114
+ describe ".stop_environment" do
115
+ before do
116
+ stub_post("/projects/3/environments/12/stop", "environment")
117
+ @environment = Gitlab.stop_environment(3, 12)
118
+ end
119
+
120
+ it "should get the correct resource" do
121
+ expect(a_post("/projects/3/environments/12/stop")).to have_been_made
122
+ end
123
+
124
+ it "should return a single pipeline" do
125
+ expect(@environment).to be_a Gitlab::ObjectifiedHash
126
+ end
127
+
128
+ it "should return information about a pipeline" do
129
+ expect(@environment.name).to eq("staging")
130
+ end
131
+ end
132
+ end
@@ -59,20 +59,18 @@ describe Gitlab::Client do
59
59
  end
60
60
 
61
61
  describe ".delete_group" do
62
- context "without description" do
63
- before do
64
- stub_delete("/groups/42", "group_delete")
65
- @group = Gitlab.delete_group(42)
66
- end
62
+ before do
63
+ stub_delete("/groups/42", "group_delete")
64
+ @group = Gitlab.delete_group(42)
65
+ end
67
66
 
68
- it "should get the correct resource" do
69
- expect(a_delete("/groups/42")).to have_been_made
70
- end
67
+ it "should get the correct resource" do
68
+ expect(a_delete("/groups/42")).to have_been_made
69
+ end
71
70
 
72
- it "should return information about a deleted group" do
73
- expect(@group.name).to eq("Gitlab-Group")
74
- expect(@group.path).to eq("gitlab-group")
75
- end
71
+ it "should return information about a deleted group" do
72
+ expect(@group.name).to eq("Gitlab-Group")
73
+ expect(@group.path).to eq("gitlab-group")
76
74
  end
77
75
  end
78
76
 
@@ -65,4 +65,36 @@ describe Gitlab::Client do
65
65
  expect(@label.color).to eq('#DD10AA')
66
66
  end
67
67
  end
68
+
69
+ describe ".subscribe_to_label" do
70
+ before do
71
+ stub_post("/projects/3/labels/Backlog/subscribe", "label")
72
+ @label = Gitlab.subscribe_to_label(3, 'Backlog')
73
+ end
74
+
75
+ it "should get the correct resource" do
76
+ expect(a_post("/projects/3/labels/Backlog/subscribe")).to have_been_made
77
+ end
78
+
79
+ it "should return information about the label subscribed to" do
80
+ expect(@label.name).to eq('Backlog')
81
+ expect(@label.subscribed).to eq(true)
82
+ end
83
+ end
84
+
85
+ describe ".unsubscribe_from_label" do
86
+ before do
87
+ stub_post("/projects/3/labels/Backlog/unsubscribe", "label_unsubscribe")
88
+ @label = Gitlab.unsubscribe_from_label(3, 'Backlog')
89
+ end
90
+
91
+ it "should get the correct resource" do
92
+ expect(a_post("/projects/3/labels/Backlog/unsubscribe")).to have_been_made
93
+ end
94
+
95
+ it "should return information about the label subscribed to" do
96
+ expect(@label.name).to eq('Backlog')
97
+ expect(@label.subscribed).to eq(false)
98
+ end
99
+ end
68
100
  end
@@ -202,4 +202,132 @@ describe Gitlab::Client do
202
202
  end
203
203
  end
204
204
  end
205
+
206
+ describe "delete note" do
207
+ context "when wall note" do
208
+ before do
209
+ stub_delete("/projects/3/notes/1201", "note")
210
+ @note = Gitlab.delete_note(3, 1201)
211
+ end
212
+
213
+ it "should get the correct resource" do
214
+ expect(a_delete("/projects/3/notes/1201")).to have_been_made
215
+ end
216
+
217
+ it "should return information about a deleted note" do
218
+ expect(@note.id).to eq(1201)
219
+ end
220
+ end
221
+
222
+ context "when issue note" do
223
+ before do
224
+ stub_delete("/projects/3/issues/7/notes/1201", "note")
225
+ @note = Gitlab.delete_issue_note(3, 7, 1201)
226
+ end
227
+
228
+ it "should get the correct resource" do
229
+ expect(a_delete("/projects/3/issues/7/notes/1201")).to have_been_made
230
+ end
231
+
232
+ it "should return information about a deleted issue note" do
233
+ expect(@note.id).to eq(1201)
234
+ end
235
+ end
236
+
237
+ context "when snippet note" do
238
+ before do
239
+ stub_delete("/projects/3/snippets/7/notes/1201", "note")
240
+ @note = Gitlab.delete_snippet_note(3, 7, 1201)
241
+ end
242
+
243
+ it "should get the correct resource" do
244
+ expect(a_delete("/projects/3/snippets/7/notes/1201")).to have_been_made
245
+ end
246
+
247
+ it "should return information about a deleted snippet note" do
248
+ expect(@note.id).to eq(1201)
249
+ end
250
+ end
251
+
252
+ context "when merge request note" do
253
+ before do
254
+ stub_delete("/projects/3/merge_requests/7/notes/1201", "note")
255
+ @note = Gitlab.delete_merge_request_note(3, 7, 1201)
256
+ end
257
+
258
+ it "should get the correct resource" do
259
+ expect(a_delete("/projects/3/merge_requests/7/notes/1201")).to have_been_made
260
+ end
261
+
262
+ it "should return information about a deleted merge request note" do
263
+ expect(@note.id).to eq(1201)
264
+ end
265
+ end
266
+ end
267
+
268
+ describe "modify note" do
269
+ context "when wall note" do
270
+ before do
271
+ stub_put("/projects/3/notes/1201", "note")
272
+ @note = Gitlab.edit_note(3, 1201, body: "edited wall note content")
273
+ end
274
+
275
+ it "should get the correct resource" do
276
+ expect(a_put("/projects/3/notes/1201").
277
+ with(body: {body: 'edited wall note content'})).to have_been_made
278
+ end
279
+
280
+ it "should return information about a modified note" do
281
+ expect(@note.id).to eq(1201)
282
+ end
283
+ end
284
+
285
+ context "when issue note" do
286
+ before do
287
+ stub_put("/projects/3/issues/7/notes/1201", "note")
288
+ @note = Gitlab.edit_issue_note(3, 7, 1201, body: "edited issue note content")
289
+ end
290
+
291
+ it "should get the correct resource" do
292
+ expect(a_put("/projects/3/issues/7/notes/1201").
293
+ with(body: {body: 'edited issue note content'})).to have_been_made
294
+ end
295
+
296
+ it "should return information about a modified issue note" do
297
+ expect(@note.id).to eq(1201)
298
+ end
299
+ end
300
+
301
+ context "when snippet note" do
302
+ before do
303
+ stub_put("/projects/3/snippets/7/notes/1201", "note")
304
+ @note = Gitlab.edit_snippet_note(3, 7, 1201, body: "edited snippet note content")
305
+ end
306
+
307
+ it "should get the correct resource" do
308
+ expect(a_put("/projects/3/snippets/7/notes/1201").
309
+ with(body: {body: 'edited snippet note content'})).to have_been_made
310
+ end
311
+
312
+ it "should return information about a modified snippet note" do
313
+ expect(@note.id).to eq(1201)
314
+ end
315
+ end
316
+
317
+ context "when merge request note" do
318
+ before do
319
+ stub_put("/projects/3/merge_requests/7/notes/1201", "note")
320
+ @note = Gitlab.edit_merge_request_note(3, 7, 1201, body: "edited merge request note content")
321
+ end
322
+
323
+ it "should get the correct resource" do
324
+ expect(a_put("/projects/3/merge_requests/7/notes/1201").
325
+ with(body: {body: 'edited merge request note content'})).to have_been_made
326
+ end
327
+
328
+ it "should return information about a modified request note" do
329
+ expect(@note.id).to eq(1201)
330
+ end
331
+ end
332
+ end
205
333
  end