gitlab 4.3.0 → 4.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. checksums.yaml +4 -4
  2. data/.dockerignore +6 -0
  3. data/.travis.yml +1 -1
  4. data/Dockerfile +8 -0
  5. data/README.md +64 -0
  6. data/docker-compose.yml +19 -0
  7. data/docker.env +2 -0
  8. data/gitlab.gemspec +4 -4
  9. data/lib/gitlab/client.rb +4 -0
  10. data/lib/gitlab/client/access_requests.rb +94 -0
  11. data/lib/gitlab/client/branches.rb +3 -3
  12. data/lib/gitlab/client/commits.rb +18 -0
  13. data/lib/gitlab/client/events.rb +58 -0
  14. data/lib/gitlab/client/group_milestones.rb +93 -0
  15. data/lib/gitlab/client/groups.rb +11 -11
  16. data/lib/gitlab/client/labels.rb +2 -2
  17. data/lib/gitlab/client/merge_requests.rb +129 -1
  18. data/lib/gitlab/client/notes.rb +21 -4
  19. data/lib/gitlab/client/projects.rb +37 -15
  20. data/lib/gitlab/client/runners.rb +11 -0
  21. data/lib/gitlab/client/sidekiq.rb +37 -0
  22. data/lib/gitlab/client/snippets.rb +3 -1
  23. data/lib/gitlab/client/tags.rb +5 -5
  24. data/lib/gitlab/version.rb +1 -1
  25. data/spec/fixtures/access_request.json +8 -0
  26. data/spec/fixtures/access_requests.json +18 -0
  27. data/spec/fixtures/approved_access_request.json +8 -0
  28. data/spec/fixtures/default_approved_access_request.json +8 -0
  29. data/spec/fixtures/group_milestone.json +1 -0
  30. data/spec/fixtures/group_milestone_issues.json +1 -0
  31. data/spec/fixtures/group_milestone_merge_requests.json +1 -0
  32. data/spec/fixtures/group_milestones.json +1 -0
  33. data/spec/fixtures/merge_request_discussion.json +39 -0
  34. data/spec/fixtures/merge_request_discussion_note.json +33 -0
  35. data/spec/fixtures/merge_request_discussions.json +41 -0
  36. data/spec/fixtures/project_commit_merge_requests.json +1 -0
  37. data/spec/fixtures/project_events.json +81 -1
  38. data/spec/fixtures/project_forks.json +50 -0
  39. data/spec/fixtures/runner_jobs.json +63 -0
  40. data/spec/fixtures/sidekiq_compound_metrics.json +36 -0
  41. data/spec/fixtures/sidekiq_job_stats.json +7 -0
  42. data/spec/fixtures/sidekiq_process_metrics.json +25 -0
  43. data/spec/fixtures/sidekiq_queue_metrics.json +8 -0
  44. data/spec/fixtures/user_contribution_events.json +101 -0
  45. data/spec/fixtures/user_events.json +40 -0
  46. data/spec/fixtures/user_projects.json +153 -0
  47. data/spec/gitlab/client/access_requests_spec.rb +141 -0
  48. data/spec/gitlab/client/branches_spec.rb +4 -2
  49. data/spec/gitlab/client/commits_spec.rb +22 -0
  50. data/spec/gitlab/client/events_spec.rb +48 -0
  51. data/spec/gitlab/client/group_milestones_spec.rb +98 -0
  52. data/spec/gitlab/client/merge_requests_spec.rb +127 -0
  53. data/spec/gitlab/client/notes_spec.rb +4 -4
  54. data/spec/gitlab/client/projects_spec.rb +37 -20
  55. data/spec/gitlab/client/runners_spec.rb +10 -0
  56. data/spec/gitlab/client/sidekiq_spec.rb +64 -0
  57. data/spec/gitlab/client/snippets_spec.rb +2 -2
  58. data/spec/gitlab/client/tags_spec.rb +44 -0
  59. data/spec/gitlab/shell_spec.rb +1 -1
  60. metadata +67 -7
@@ -86,12 +86,14 @@ describe Gitlab::Client do
86
86
 
87
87
  describe ".create_branch" do
88
88
  before do
89
- stub_post("/projects/3/repository/branches", "branch")
89
+ stub_post("/projects/3/repository/branches", "branch").with(query: { branch: 'api', ref: "master"})
90
90
  @branch = Gitlab.create_branch(3, "api", "master")
91
91
  end
92
92
 
93
93
  it "gets the correct resource" do
94
- expect(a_post("/projects/3/repository/branches")).to have_been_made
94
+ expect(
95
+ a_post("/projects/3/repository/branches").with(query: { branch: 'api', ref: "master"})
96
+ ).to have_been_made
95
97
  end
96
98
 
97
99
  it "returns information about a new repository branch" do
@@ -8,6 +8,7 @@ describe Gitlab::Client do
8
8
  it { is_expected.to respond_to :repo_create_commit_comment }
9
9
  it { is_expected.to respond_to :repo_commit_status }
10
10
  it { is_expected.to respond_to :repo_update_commit_status }
11
+ it { is_expected.to respond_to :repo_commit_merge_requests }
11
12
 
12
13
  describe ".commits" do
13
14
  before do
@@ -165,4 +166,25 @@ describe Gitlab::Client do
165
166
  expect(@commit.id).to eq('ed899a2f4b50b4370feeea94676502b42383c746')
166
167
  end
167
168
  end
169
+
170
+ describe ".repo_commit_merge_requests" do
171
+ before do
172
+ stub_get("/projects/3/repository/commits/6104942438c14ec7bd21c6cd5bd995272b3faff6/merge_requests", "project_commit_merge_requests")
173
+ @commit_merge_requests = Gitlab.commit_merge_requests(3, '6104942438c14ec7bd21c6cd5bd995272b3faff6')
174
+ end
175
+
176
+ it "gets the correct resource" do
177
+ expect(a_get("/projects/3/repository/commits/6104942438c14ec7bd21c6cd5bd995272b3faff6/merge_requests")).
178
+ to have_been_made
179
+ end
180
+
181
+ it "returns commit's associated merge_requests" do
182
+ expect(@commit_merge_requests).to be_a Gitlab::PaginatedResponse
183
+ expect(@commit_merge_requests.length).to eq(2)
184
+ expect(@commit_merge_requests[0].iid).to eq(1)
185
+ expect(@commit_merge_requests[0].author.id).to eq(1)
186
+ expect(@commit_merge_requests[1].iid).to eq(2)
187
+ expect(@commit_merge_requests[1].author.id).to eq(2)
188
+ end
189
+ end
168
190
  end
@@ -0,0 +1,48 @@
1
+ require 'spec_helper'
2
+
3
+ describe Gitlab::Client do
4
+ describe ".events" do
5
+ before do
6
+ stub_get("/events", "user_events")
7
+ @events = Gitlab.events()
8
+ end
9
+
10
+ it "gets the correct resource" do
11
+ expect(a_get("/events")).to have_been_made
12
+ end
13
+
14
+ it "it returns a response of user's events" do
15
+ expect(@events).to be_a Gitlab::PaginatedResponse
16
+ end
17
+ end
18
+
19
+ describe ".user_events" do
20
+ before do
21
+ stub_get("/users/1/events", "user_events")
22
+ @events = Gitlab.user_events(1)
23
+ end
24
+
25
+ it "gets the correct resource" do
26
+ expect(a_get("/users/1/events")).to have_been_made
27
+ end
28
+
29
+ it "returns a response of user's contribution events" do
30
+ expect(@events).to be_a Gitlab::PaginatedResponse
31
+ end
32
+ end
33
+
34
+ describe '.project_events' do
35
+ before do
36
+ stub_get("/1/events", "project_events")
37
+ @events = Gitlab.project_events(1)
38
+ end
39
+
40
+ it "gets the correct resource" do
41
+ expect(a_get("/1/events")).to have_been_made
42
+ end
43
+
44
+ it "returns a response of project's visible events" do
45
+ expect(@events).to be_a Gitlab::PaginatedResponse
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,98 @@
1
+ require 'spec_helper'
2
+
3
+ describe Gitlab::Client do
4
+ describe ".group_milestones" do
5
+ before do
6
+ stub_get("/groups/3/milestones", "group_milestones")
7
+ @milestones = Gitlab.group_milestones(3)
8
+ end
9
+
10
+ it "gets the correct resource" do
11
+ expect(a_get("/groups/3/milestones")).to have_been_made
12
+ end
13
+
14
+ it "returns a paginated response of group's milestones" do
15
+ expect(@milestones).to be_a Gitlab::PaginatedResponse
16
+ expect(@milestones.first.group_id).to eq(3)
17
+ end
18
+ end
19
+
20
+ describe ".group_milestone" do
21
+ before do
22
+ stub_get("/groups/3/milestones/1", "group_milestone")
23
+ @milestone = Gitlab.group_milestone(3, 1)
24
+ end
25
+
26
+ it "gets the correct resource" do
27
+ expect(a_get("/groups/3/milestones/1")).to have_been_made
28
+ end
29
+
30
+ it "returns information about a milestone" do
31
+ expect(@milestone.group_id).to eq(3)
32
+ end
33
+ end
34
+
35
+ describe ".create_group_milestone" do
36
+ before do
37
+ stub_post("/groups/3/milestones", "group_milestone")
38
+ @milestone = Gitlab.create_group_milestone(3, 'title')
39
+ end
40
+
41
+ it "gets the correct resource" do
42
+ expect(a_post("/groups/3/milestones").
43
+ with(body: { title: 'title' })).to have_been_made
44
+ end
45
+
46
+ it "returns information about a created milestone" do
47
+ expect(@milestone.group_id).to eq(3)
48
+ end
49
+ end
50
+
51
+ describe ".edit_group_milestone" do
52
+ before do
53
+ stub_put("/groups/3/milestones/33", "group_milestone")
54
+ @milestone = Gitlab.edit_group_milestone(3, 33, title: 'title')
55
+ end
56
+
57
+ it "gets the correct resource" do
58
+ expect(a_put("/groups/3/milestones/33").
59
+ with(body: { title: 'title' })).to have_been_made
60
+ end
61
+
62
+ it "returns information about an edited milestone" do
63
+ expect(@milestone.group_id).to eq(3)
64
+ end
65
+ end
66
+
67
+ describe ".group_milestone_issues" do
68
+ before do
69
+ stub_get("/groups/3/milestones/1/issues", "group_milestone_issues")
70
+ @milestone_issues = Gitlab.group_milestone_issues(3, 1)
71
+ end
72
+
73
+ it "gets the correct resource" do
74
+ expect(a_get("/groups/3/milestones/1/issues")).to have_been_made
75
+ end
76
+
77
+ it "returns a paginated response of milestone's issues" do
78
+ expect(@milestone_issues).to be_a Gitlab::PaginatedResponse
79
+ expect(@milestone_issues.first.milestone.id).to eq(1)
80
+ end
81
+ end
82
+
83
+ describe ".group_milestone_merge_requests" do
84
+ before do
85
+ stub_get("/groups/3/milestones/1/merge_requests", "group_milestone_merge_requests")
86
+ @milestone_merge_requests = Gitlab.group_milestone_merge_requests(3, 1)
87
+ end
88
+
89
+ it "gets the correct resource" do
90
+ expect(a_get("/groups/3/milestones/1/merge_requests")).to have_been_made
91
+ end
92
+
93
+ it "returns a paginated response of milestone's merge_requests" do
94
+ expect(@milestone_merge_requests).to be_a Gitlab::PaginatedResponse
95
+ expect(@milestone_merge_requests.first.milestone.id).to eq(1)
96
+ end
97
+ end
98
+ end
@@ -1,6 +1,21 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Gitlab::Client do
4
+ describe ".user_merge_requests" do
5
+ before do
6
+ stub_get("/merge_requests", "merge_requests")
7
+ @user_merge_requests = Gitlab.user_merge_requests
8
+ end
9
+
10
+ it "gets the correct resource" do
11
+ expect(a_get("/merge_requests")).to have_been_made
12
+ end
13
+
14
+ it "returns a paginated response of user merge requests" do
15
+ expect(@user_merge_requests).to be_a Gitlab::PaginatedResponse
16
+ end
17
+ end
18
+
4
19
  describe ".merge_requests" do
5
20
  before do
6
21
  stub_get("/projects/3/merge_requests", "merge_requests")
@@ -221,4 +236,116 @@ describe Gitlab::Client do
221
236
  expect(@merge_request.project_id).to eq(3)
222
237
  end
223
238
  end
239
+
240
+ describe ".merge_request_discussions" do
241
+ before do
242
+ stub_get("/projects/3/merge_requests/2/discussions", "merge_request_discussions")
243
+ @discussions = Gitlab.merge_request_discussions(3, 2)
244
+ end
245
+
246
+ it "gets the correct resource" do
247
+ expect(a_get("/projects/3/merge_requests/2/discussions")).to have_been_made
248
+ end
249
+
250
+ it "returns information about the discussions" do
251
+ expect(@discussions.length).to eq(1)
252
+ expect(@discussions.first.id).to eq('7d66bf19bf835e6a4666130544ba1b5c343fc705')
253
+ end
254
+ end
255
+
256
+ describe ".merge_request_discussion" do
257
+ before do
258
+ stub_get("/projects/3/merge_requests/2/discussions/1", "merge_request_discussion")
259
+ @discussion = Gitlab.merge_request_discussion(3, 2, 1)
260
+ end
261
+
262
+ it "gets the correct resource" do
263
+ expect(a_get("/projects/3/merge_requests/2/discussions/1")).to have_been_made
264
+ end
265
+
266
+ it "returns information about the discussions" do
267
+ expect(@discussion.id).to eq('7d66bf19bf835e6a4666130544ba1b5c343fc705')
268
+ end
269
+ end
270
+
271
+ describe ".create_merge_request_discussion" do
272
+ before do
273
+ stub_post("/projects/3/merge_requests/2/discussions", "merge_request_discussion")
274
+ @discussion = Gitlab.create_merge_request_discussion(3, 2, body: 'Discussion', position: {old_line: 1})
275
+ end
276
+
277
+ it "posts the correct resource" do
278
+ expect(a_post("/projects/3/merge_requests/2/discussions").
279
+ with(body: 'body=Discussion&position[old_line]=1')).to have_been_made
280
+ end
281
+
282
+ it "returns information about the discussions" do
283
+ expect(@discussion.id).to eq('7d66bf19bf835e6a4666130544ba1b5c343fc705')
284
+ end
285
+ end
286
+
287
+ describe ".resolve_merge_request_discussion" do
288
+ before do
289
+ stub_put("/projects/3/merge_requests/2/discussions/1", "merge_request_discussion")
290
+ @discussion = Gitlab.resolve_merge_request_discussion(3, 2, 1, resolved: true)
291
+ end
292
+
293
+ it "puts the correct resource" do
294
+ expect(a_put("/projects/3/merge_requests/2/discussions/1").
295
+ with(body: 'resolved=true')).to have_been_made
296
+ end
297
+
298
+ it "returns information about the discussions" do
299
+ expect(@discussion.id).to eq('7d66bf19bf835e6a4666130544ba1b5c343fc705')
300
+ note = @discussion.notes.first
301
+ expect(note['id']).to eq(1758)
302
+ end
303
+ end
304
+
305
+ describe ".create_merge_request_discussion_note" do
306
+ before do
307
+ stub_post("/projects/3/merge_requests/2/discussions/1/notes", "merge_request_discussion_note")
308
+ @note = Gitlab.create_merge_request_discussion_note(3, 2, 1, body: 'note')
309
+ end
310
+
311
+ it "posts the correct resource" do
312
+ expect(a_post("/projects/3/merge_requests/2/discussions/1/notes").
313
+ with(body: 'body=note')).to have_been_made
314
+ end
315
+
316
+ it "returns information about the note" do
317
+ expect(@note.id).to eq(1775)
318
+ end
319
+ end
320
+
321
+ describe ".update_merge_request_discussion_note" do
322
+ before do
323
+ stub_put("/projects/3/merge_requests/2/discussions/1/notes/1", "merge_request_discussion_note")
324
+ @note = Gitlab.update_merge_request_discussion_note(3, 2, 1, 1, body: 'note2')
325
+ end
326
+
327
+ it "puts the correct resource" do
328
+ expect(a_put("/projects/3/merge_requests/2/discussions/1/notes/1").
329
+ with(body: 'body=note2')).to have_been_made
330
+ end
331
+
332
+ it "returns information about the note" do
333
+ expect(@note.id).to eq(1775)
334
+ end
335
+ end
336
+
337
+ describe ".delete_merge_request_discussion_note" do
338
+ before do
339
+ stub_request(:delete, "https://api.example.com/projects/3/merge_requests/2/discussions/1/notes/1").to_return(body: '')
340
+ @note = Gitlab.delete_merge_request_discussion_note(3, 2, 1, 1)
341
+ end
342
+
343
+ it "deletes the correct resource" do
344
+ expect(a_delete("/projects/3/merge_requests/2/discussions/1/notes/1")).to have_been_made
345
+ end
346
+
347
+ it "returns nothing" do
348
+ expect(@note).to be_falsy
349
+ end
350
+ end
224
351
  end
@@ -269,7 +269,7 @@ describe Gitlab::Client do
269
269
  context "when wall note" do
270
270
  before do
271
271
  stub_put("/projects/3/notes/1201", "note")
272
- @note = Gitlab.edit_note(3, 1201, body: "edited wall note content")
272
+ @note = Gitlab.edit_note(3, 1201, "edited wall note content")
273
273
  end
274
274
 
275
275
  it "gets the correct resource" do
@@ -285,7 +285,7 @@ describe Gitlab::Client do
285
285
  context "when issue note" do
286
286
  before do
287
287
  stub_put("/projects/3/issues/7/notes/1201", "note")
288
- @note = Gitlab.edit_issue_note(3, 7, 1201, body: "edited issue note content")
288
+ @note = Gitlab.edit_issue_note(3, 7, 1201, "edited issue note content")
289
289
  end
290
290
 
291
291
  it "gets the correct resource" do
@@ -301,7 +301,7 @@ describe Gitlab::Client do
301
301
  context "when snippet note" do
302
302
  before do
303
303
  stub_put("/projects/3/snippets/7/notes/1201", "note")
304
- @note = Gitlab.edit_snippet_note(3, 7, 1201, body: "edited snippet note content")
304
+ @note = Gitlab.edit_snippet_note(3, 7, 1201, "edited snippet note content")
305
305
  end
306
306
 
307
307
  it "gets the correct resource" do
@@ -317,7 +317,7 @@ describe Gitlab::Client do
317
317
  context "when merge request note" do
318
318
  before do
319
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")
320
+ @note = Gitlab.edit_merge_request_note(3, 7, 1201, "edited merge request note content")
321
321
  end
322
322
 
323
323
  it "gets the correct resource" do
@@ -53,26 +53,6 @@ describe Gitlab::Client do
53
53
  end
54
54
  end
55
55
 
56
- describe ".project_events" do
57
- before do
58
- stub_get("/projects/2/events", "project_events")
59
- @events = Gitlab.project_events(2)
60
- end
61
-
62
- it "gets the correct resource" do
63
- expect(a_get("/projects/2/events")).to have_been_made
64
- end
65
-
66
- it "returns a paginated response of events" do
67
- expect(@events).to be_a Gitlab::PaginatedResponse
68
- expect(@events.size).to eq(2)
69
- end
70
-
71
- it "returns the action name of the event" do
72
- expect(@events.first.action_name).to eq("opened")
73
- end
74
- end
75
-
76
56
  describe ".create_project" do
77
57
  before do
78
58
  stub_post("/projects", "project")
@@ -155,6 +135,23 @@ describe Gitlab::Client do
155
135
  end
156
136
  end
157
137
 
138
+ describe ".project_forks" do
139
+ before do
140
+ stub_get("/projects/3/forks", "project_forks")
141
+ @project_forks = Gitlab.project_forks(3)
142
+ end
143
+
144
+ it "gets the correct resource" do
145
+ expect(a_get("/projects/3/forks")).to have_been_made
146
+ end
147
+
148
+ it "returns a paginated response of projects found" do
149
+ expect(@project_forks).to be_a Gitlab::PaginatedResponse
150
+ expect(@project_forks.first.name).to eq("gitlab")
151
+ expect(@project_forks.first.owner.name).to eq("Administrator")
152
+ end
153
+ end
154
+
158
155
  describe ".team_members" do
159
156
  before do
160
157
  stub_get("/projects/3/members", "team_members")
@@ -610,4 +607,24 @@ describe Gitlab::Client do
610
607
  expect(@unstarred_project.id).to eq(3)
611
608
  end
612
609
  end
610
+
611
+ describe ".user_projects" do
612
+ let(:user_id) { 1 }
613
+ let(:project_id) { 1 }
614
+
615
+ before do
616
+ stub_get("/users/#{user_id}/projects", "user_projects")
617
+ @user_projects = Gitlab.user_projects(user_id)
618
+ end
619
+
620
+ it "gets the correct resource" do
621
+ expect(a_get("/users/#{user_id}/projects")).to have_been_made
622
+ end
623
+
624
+ it "returns a paginated response of projects" do
625
+ expect(@user_projects).to be_a Gitlab::PaginatedResponse
626
+ expect(@user_projects.first.id).to eq(project_id)
627
+ expect(@user_projects.first.owner.id).to eq(user_id)
628
+ end
629
+ end
613
630
  end
@@ -130,6 +130,16 @@ describe Gitlab::Client do
130
130
  end
131
131
  end
132
132
 
133
+ describe '.runner_jobs' do
134
+ before do
135
+ stub_get('/runners/1/jobs', 'runner_jobs')
136
+ @jobs = Gitlab.runner_jobs(1)
137
+ end
138
+ it 'gets the correct resource' do
139
+ expect(a_get('/runners/1/jobs')).to have_been_made
140
+ end
141
+ end
142
+
133
143
  describe ".project_runners" do
134
144
  before do
135
145
  stub_get("/projects/1/runners", "project_runners")