gitlab 4.2.0 → 4.18.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 (271) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +4 -2
  3. data/LICENSE.txt +1 -1
  4. data/README.md +96 -25
  5. data/exe/gitlab +5 -1
  6. data/lib/gitlab/api.rb +8 -3
  7. data/lib/gitlab/cli.rb +15 -15
  8. data/lib/gitlab/cli_helpers.rb +63 -61
  9. data/lib/gitlab/client/access_requests.rb +103 -0
  10. data/lib/gitlab/client/application_settings.rb +172 -0
  11. data/lib/gitlab/client/avatar.rb +21 -0
  12. data/lib/gitlab/client/award_emojis.rb +5 -3
  13. data/lib/gitlab/client/boards.rb +62 -4
  14. data/lib/gitlab/client/branches.rb +53 -14
  15. data/lib/gitlab/client/broadcast_messages.rb +75 -0
  16. data/lib/gitlab/client/build_variables.rb +78 -9
  17. data/lib/gitlab/client/builds.rb +13 -11
  18. data/lib/gitlab/client/commits.rb +89 -19
  19. data/lib/gitlab/client/container_registry.rb +85 -0
  20. data/lib/gitlab/client/deployments.rb +34 -0
  21. data/lib/gitlab/client/environments.rb +5 -3
  22. data/lib/gitlab/client/epic_issues.rb +23 -0
  23. data/lib/gitlab/client/epics.rb +73 -0
  24. data/lib/gitlab/client/events.rb +60 -0
  25. data/lib/gitlab/client/features.rb +48 -0
  26. data/lib/gitlab/client/group_badges.rb +88 -0
  27. data/lib/gitlab/client/group_boards.rb +141 -0
  28. data/lib/gitlab/client/group_labels.rb +88 -0
  29. data/lib/gitlab/client/group_milestones.rb +94 -0
  30. data/lib/gitlab/client/groups.rb +197 -17
  31. data/lib/gitlab/client/issue_links.rb +48 -0
  32. data/lib/gitlab/client/issues.rb +98 -4
  33. data/lib/gitlab/client/jobs.rb +96 -8
  34. data/lib/gitlab/client/keys.rb +13 -0
  35. data/lib/gitlab/client/labels.rb +7 -5
  36. data/lib/gitlab/client/lint.rb +19 -0
  37. data/lib/gitlab/client/markdown.rb +23 -0
  38. data/lib/gitlab/client/merge_request_approvals.rb +265 -0
  39. data/lib/gitlab/client/merge_requests.rb +237 -9
  40. data/lib/gitlab/client/milestones.rb +19 -5
  41. data/lib/gitlab/client/namespaces.rb +4 -2
  42. data/lib/gitlab/client/notes.rb +58 -12
  43. data/lib/gitlab/client/pipeline_schedules.rb +147 -0
  44. data/lib/gitlab/client/pipeline_triggers.rb +12 -10
  45. data/lib/gitlab/client/pipelines.rb +40 -3
  46. data/lib/gitlab/client/project_badges.rb +85 -0
  47. data/lib/gitlab/client/project_clusters.rb +83 -0
  48. data/lib/gitlab/client/project_release_links.rb +76 -0
  49. data/lib/gitlab/client/project_releases.rb +79 -0
  50. data/lib/gitlab/client/projects.rb +280 -47
  51. data/lib/gitlab/client/protected_tags.rb +59 -0
  52. data/lib/gitlab/client/remote_mirrors.rb +51 -0
  53. data/lib/gitlab/client/repositories.rb +60 -6
  54. data/lib/gitlab/client/repository_files.rb +23 -5
  55. data/lib/gitlab/client/repository_submodules.rb +27 -0
  56. data/lib/gitlab/client/resource_label_events.rb +82 -0
  57. data/lib/gitlab/client/resource_state_events.rb +57 -0
  58. data/lib/gitlab/client/runners.rb +111 -15
  59. data/lib/gitlab/client/search.rb +66 -0
  60. data/lib/gitlab/client/services.rb +4 -1
  61. data/lib/gitlab/client/sidekiq.rb +39 -0
  62. data/lib/gitlab/client/snippets.rb +8 -4
  63. data/lib/gitlab/client/system_hooks.rb +9 -7
  64. data/lib/gitlab/client/tags.rb +15 -14
  65. data/lib/gitlab/client/templates.rb +100 -0
  66. data/lib/gitlab/client/todos.rb +7 -5
  67. data/lib/gitlab/client/user_snippets.rb +114 -0
  68. data/lib/gitlab/client/users.rb +166 -30
  69. data/lib/gitlab/client/versions.rb +18 -0
  70. data/lib/gitlab/client/wikis.rb +79 -0
  71. data/lib/gitlab/client.rb +49 -12
  72. data/lib/gitlab/configuration.rb +8 -6
  73. data/lib/gitlab/error.rb +74 -5
  74. data/lib/gitlab/file_response.rb +5 -3
  75. data/lib/gitlab/help.rb +19 -20
  76. data/lib/gitlab/objectified_hash.rb +27 -10
  77. data/lib/gitlab/page_links.rb +11 -9
  78. data/lib/gitlab/paginated_response.rb +37 -24
  79. data/lib/gitlab/request.rb +42 -53
  80. data/lib/gitlab/shell.rb +11 -12
  81. data/lib/gitlab/shell_history.rb +11 -13
  82. data/lib/gitlab/version.rb +3 -1
  83. data/lib/gitlab.rb +19 -8
  84. metadata +50 -395
  85. data/.gitignore +0 -22
  86. data/.travis.yml +0 -8
  87. data/CONTRIBUTING.md +0 -195
  88. data/Gemfile +0 -4
  89. data/Rakefile +0 -9
  90. data/bin/console +0 -10
  91. data/bin/setup +0 -6
  92. data/gitlab.gemspec +0 -31
  93. data/spec/fixtures/board_list.json +0 -1
  94. data/spec/fixtures/board_lists.json +0 -1
  95. data/spec/fixtures/boards.json +0 -1
  96. data/spec/fixtures/branch.json +0 -1
  97. data/spec/fixtures/branch_delete.json +0 -3
  98. data/spec/fixtures/branches.json +0 -1
  99. data/spec/fixtures/build.json +0 -38
  100. data/spec/fixtures/build_artifacts.json +0 -0
  101. data/spec/fixtures/build_cancel.json +0 -24
  102. data/spec/fixtures/build_erase.json +0 -24
  103. data/spec/fixtures/build_retry.json +0 -24
  104. data/spec/fixtures/builds.json +0 -78
  105. data/spec/fixtures/builds_commits.json +0 -64
  106. data/spec/fixtures/compare_merge_request_diff.json +0 -31
  107. data/spec/fixtures/empty.json +0 -0
  108. data/spec/fixtures/environment.json +0 -6
  109. data/spec/fixtures/environments.json +0 -14
  110. data/spec/fixtures/error_already_exists.json +0 -1
  111. data/spec/fixtures/error_project_not_found.json +0 -1
  112. data/spec/fixtures/get_repository_file.json +0 -1
  113. data/spec/fixtures/group.json +0 -60
  114. data/spec/fixtures/group_create.json +0 -1
  115. data/spec/fixtures/group_create_with_description.json +0 -1
  116. data/spec/fixtures/group_delete.json +0 -1
  117. data/spec/fixtures/group_member.json +0 -1
  118. data/spec/fixtures/group_member_delete.json +0 -1
  119. data/spec/fixtures/group_member_edit.json +0 -1
  120. data/spec/fixtures/group_members.json +0 -1
  121. data/spec/fixtures/group_projects.json +0 -44
  122. data/spec/fixtures/group_search.json +0 -2
  123. data/spec/fixtures/groups.json +0 -2
  124. data/spec/fixtures/issue.json +0 -1
  125. data/spec/fixtures/issue_award_emoji.json +0 -16
  126. data/spec/fixtures/issue_award_emojis.json +0 -34
  127. data/spec/fixtures/issues.json +0 -1
  128. data/spec/fixtures/job.json +0 -43
  129. data/spec/fixtures/job_trace.json +0 -1
  130. data/spec/fixtures/jobs.json +0 -91
  131. data/spec/fixtures/key.json +0 -1
  132. data/spec/fixtures/keys.json +0 -1
  133. data/spec/fixtures/label.json +0 -1
  134. data/spec/fixtures/label_unsubscribe.json +0 -1
  135. data/spec/fixtures/labels.json +0 -1
  136. data/spec/fixtures/merge_request.json +0 -1
  137. data/spec/fixtures/merge_request_award_emoji.json +0 -16
  138. data/spec/fixtures/merge_request_award_emojis.json +0 -34
  139. data/spec/fixtures/merge_request_changes.json +0 -1
  140. data/spec/fixtures/merge_request_closes_issues.json +0 -1
  141. data/spec/fixtures/merge_request_comment.json +0 -1
  142. data/spec/fixtures/merge_request_comments.json +0 -1
  143. data/spec/fixtures/merge_request_commits.json +0 -1
  144. data/spec/fixtures/merge_requests.json +0 -1
  145. data/spec/fixtures/milestone.json +0 -1
  146. data/spec/fixtures/milestone_issues.json +0 -1
  147. data/spec/fixtures/milestone_merge_requests.json +0 -1
  148. data/spec/fixtures/milestones.json +0 -1
  149. data/spec/fixtures/namespaces.json +0 -1
  150. data/spec/fixtures/note.json +0 -1
  151. data/spec/fixtures/note_award_emoji.json +0 -16
  152. data/spec/fixtures/note_award_emojis.json +0 -18
  153. data/spec/fixtures/notes.json +0 -1
  154. data/spec/fixtures/pipeline.json +0 -23
  155. data/spec/fixtures/pipeline_cancel.json +0 -23
  156. data/spec/fixtures/pipeline_create.json +0 -23
  157. data/spec/fixtures/pipeline_jobs.json +0 -91
  158. data/spec/fixtures/pipeline_retry.json +0 -23
  159. data/spec/fixtures/pipelines.json +0 -48
  160. data/spec/fixtures/project.json +0 -1
  161. data/spec/fixtures/project_commit.json +0 -13
  162. data/spec/fixtures/project_commit_comment.json +0 -1
  163. data/spec/fixtures/project_commit_comments.json +0 -1
  164. data/spec/fixtures/project_commit_create.json +0 -22
  165. data/spec/fixtures/project_commit_diff.json +0 -10
  166. data/spec/fixtures/project_commit_status.json +0 -42
  167. data/spec/fixtures/project_commits.json +0 -1
  168. data/spec/fixtures/project_edit.json +0 -21
  169. data/spec/fixtures/project_events.json +0 -1
  170. data/spec/fixtures/project_for_user.json +0 -1
  171. data/spec/fixtures/project_fork.json +0 -50
  172. data/spec/fixtures/project_fork_link.json +0 -1
  173. data/spec/fixtures/project_forked_for_user.json +0 -50
  174. data/spec/fixtures/project_hook.json +0 -1
  175. data/spec/fixtures/project_hooks.json +0 -1
  176. data/spec/fixtures/project_issues.json +0 -1
  177. data/spec/fixtures/project_key.json +0 -6
  178. data/spec/fixtures/project_keys.json +0 -6
  179. data/spec/fixtures/project_runner_enable.json +0 -7
  180. data/spec/fixtures/project_runners.json +0 -16
  181. data/spec/fixtures/project_search.json +0 -1
  182. data/spec/fixtures/project_star.json +0 -44
  183. data/spec/fixtures/project_tag_annotated.json +0 -1
  184. data/spec/fixtures/project_tag_lightweight.json +0 -1
  185. data/spec/fixtures/project_tags.json +0 -1
  186. data/spec/fixtures/project_unstar.json +0 -44
  187. data/spec/fixtures/project_update_commit_status.json +0 -20
  188. data/spec/fixtures/projects.json +0 -1
  189. data/spec/fixtures/push_rule.json +0 -1
  190. data/spec/fixtures/raw_file.json +0 -2
  191. data/spec/fixtures/release_create.json +0 -1
  192. data/spec/fixtures/release_update.json +0 -1
  193. data/spec/fixtures/repository_file.json +0 -1
  194. data/spec/fixtures/run_trigger.json +0 -1
  195. data/spec/fixtures/runner.json +0 -26
  196. data/spec/fixtures/runner_delete.json +0 -7
  197. data/spec/fixtures/runner_edit.json +0 -26
  198. data/spec/fixtures/runners.json +0 -16
  199. data/spec/fixtures/runners_all.json +0 -30
  200. data/spec/fixtures/service.json +0 -1
  201. data/spec/fixtures/session.json +0 -1
  202. data/spec/fixtures/shell_history.json +0 -2
  203. data/spec/fixtures/snippet.json +0 -1
  204. data/spec/fixtures/snippet_award_emoji.json +0 -16
  205. data/spec/fixtures/snippet_award_emojis.json +0 -34
  206. data/spec/fixtures/snippet_content.json +0 -3
  207. data/spec/fixtures/snippets.json +0 -1
  208. data/spec/fixtures/system_hook.json +0 -1
  209. data/spec/fixtures/system_hooks.json +0 -1
  210. data/spec/fixtures/tag.json +0 -1
  211. data/spec/fixtures/tag_create.json +0 -1
  212. data/spec/fixtures/tag_create_with_description.json +0 -1
  213. data/spec/fixtures/tag_delete.json +0 -1
  214. data/spec/fixtures/tags.json +0 -1
  215. data/spec/fixtures/team_member.json +0 -1
  216. data/spec/fixtures/team_members.json +0 -1
  217. data/spec/fixtures/todo.json +0 -73
  218. data/spec/fixtures/todos.json +0 -148
  219. data/spec/fixtures/tree.json +0 -1
  220. data/spec/fixtures/trigger.json +0 -10
  221. data/spec/fixtures/triggers.json +0 -12
  222. data/spec/fixtures/user.json +0 -1
  223. data/spec/fixtures/user_block_unblock.json +0 -1
  224. data/spec/fixtures/user_email.json +0 -1
  225. data/spec/fixtures/user_emails.json +0 -1
  226. data/spec/fixtures/user_search.json +0 -1
  227. data/spec/fixtures/users.json +0 -1
  228. data/spec/fixtures/variable.json +0 -4
  229. data/spec/fixtures/variables.json +0 -10
  230. data/spec/gitlab/cli_helpers_spec.rb +0 -57
  231. data/spec/gitlab/cli_spec.rb +0 -119
  232. data/spec/gitlab/client/award_emojis_spec.rb +0 -391
  233. data/spec/gitlab/client/boards_spec.rb +0 -94
  234. data/spec/gitlab/client/branches_spec.rb +0 -116
  235. data/spec/gitlab/client/build_variables_spec.rb +0 -86
  236. data/spec/gitlab/client/builds_spec.rb +0 -148
  237. data/spec/gitlab/client/client_spec.rb +0 -11
  238. data/spec/gitlab/client/commits_spec.rb +0 -168
  239. data/spec/gitlab/client/environments_spec.rb +0 -132
  240. data/spec/gitlab/client/groups_spec.rb +0 -195
  241. data/spec/gitlab/client/issues_spec.rb +0 -186
  242. data/spec/gitlab/client/jobs_spec.rb +0 -135
  243. data/spec/gitlab/client/keys_spec.rb +0 -19
  244. data/spec/gitlab/client/labels_spec.rb +0 -100
  245. data/spec/gitlab/client/merge_requests_spec.rb +0 -224
  246. data/spec/gitlab/client/milestones_spec.rb +0 -98
  247. data/spec/gitlab/client/namespaces_spec.rb +0 -22
  248. data/spec/gitlab/client/notes_spec.rb +0 -333
  249. data/spec/gitlab/client/pipeline_triggers_spec.rb +0 -157
  250. data/spec/gitlab/client/pipelines_spec.rb +0 -95
  251. data/spec/gitlab/client/projects_spec.rb +0 -613
  252. data/spec/gitlab/client/repositories_spec.rb +0 -94
  253. data/spec/gitlab/client/repository_files_spec.rb +0 -95
  254. data/spec/gitlab/client/runners_spec.rb +0 -185
  255. data/spec/gitlab/client/services_spec.rb +0 -55
  256. data/spec/gitlab/client/snippets_spec.rb +0 -100
  257. data/spec/gitlab/client/system_hooks_spec.rb +0 -69
  258. data/spec/gitlab/client/tags_spec.rb +0 -109
  259. data/spec/gitlab/client/todos_spec.rb +0 -45
  260. data/spec/gitlab/client/users_spec.rb +0 -418
  261. data/spec/gitlab/error_spec.rb +0 -45
  262. data/spec/gitlab/file_response_spec.rb +0 -33
  263. data/spec/gitlab/help_spec.rb +0 -46
  264. data/spec/gitlab/objectified_hash_spec.rb +0 -48
  265. data/spec/gitlab/page_links_spec.rb +0 -16
  266. data/spec/gitlab/paginated_response_spec.rb +0 -60
  267. data/spec/gitlab/request_spec.rb +0 -73
  268. data/spec/gitlab/shell_history_spec.rb +0 -53
  269. data/spec/gitlab/shell_spec.rb +0 -80
  270. data/spec/gitlab_spec.rb +0 -97
  271. data/spec/spec_helper.rb +0 -74
@@ -1,613 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Gitlab::Client do
4
- it { should respond_to :search_projects }
5
-
6
- describe ".projects" do
7
- before do
8
- stub_get("/projects", "projects")
9
- @projects = Gitlab.projects
10
- end
11
-
12
- it "should get the correct resource" do
13
- expect(a_get("/projects")).to have_been_made
14
- end
15
-
16
- it "should return a paginated response of projects" do
17
- expect(@projects).to be_a Gitlab::PaginatedResponse
18
- expect(@projects.first.name).to eq("Brute")
19
- expect(@projects.first.owner.name).to eq("John Smith")
20
- end
21
- end
22
-
23
- describe ".project_search" do
24
- before do
25
- stub_get("/projects?search=Gitlab", "project_search")
26
- @project_search = Gitlab.project_search("Gitlab")
27
- end
28
-
29
- it "should get the correct resource" do
30
- expect(a_get("/projects?search=Gitlab")).to have_been_made
31
- end
32
-
33
- it "should return a paginated response of projects found" do
34
- expect(@project_search).to be_a Gitlab::PaginatedResponse
35
- expect(@project_search.first.name).to eq("Gitlab")
36
- expect(@project_search.first.owner.name).to eq("John Smith")
37
- end
38
- end
39
-
40
- describe ".project" do
41
- before do
42
- stub_get("/projects/3", "project")
43
- @project = Gitlab.project(3)
44
- end
45
-
46
- it "should get the correct resource" do
47
- expect(a_get("/projects/3")).to have_been_made
48
- end
49
-
50
- it "should return information about a project" do
51
- expect(@project.name).to eq("Gitlab")
52
- expect(@project.owner.name).to eq("John Smith")
53
- end
54
- end
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 "should get the correct resource" do
63
- expect(a_get("/projects/2/events")).to have_been_made
64
- end
65
-
66
- it "should return 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 "should return the action name of the event" do
72
- expect(@events.first.action_name).to eq("opened")
73
- end
74
- end
75
-
76
- describe ".create_project" do
77
- before do
78
- stub_post("/projects", "project")
79
- @project = Gitlab.create_project('Gitlab')
80
- end
81
-
82
- it "should get the correct resource" do
83
- expect(a_post("/projects")).to have_been_made
84
- end
85
-
86
- it "should return information about a created project" do
87
- expect(@project.name).to eq("Gitlab")
88
- expect(@project.owner.name).to eq("John Smith")
89
- end
90
- end
91
-
92
- describe ".create_project for user" do
93
- before do
94
- stub_post("/users", "user")
95
- @owner = Gitlab.create_user("john@example.com", "pass", name: 'John Owner')
96
- stub_post("/projects/user/#{@owner.id}", "project_for_user")
97
- @project = Gitlab.create_project('Brute', user_id: @owner.id)
98
- end
99
-
100
- it "should return information about a created project" do
101
- expect(@project.name).to eq("Brute")
102
- expect(@project.owner.name).to eq("John Owner")
103
- end
104
- end
105
-
106
- describe ".delete_project" do
107
- before do
108
- stub_delete("/projects/Gitlab", "project")
109
- @project = Gitlab.delete_project('Gitlab')
110
- end
111
-
112
- it "should get the correct resource" do
113
- expect(a_delete("/projects/Gitlab")).to have_been_made
114
- end
115
-
116
- it "should return information about a deleted project" do
117
- expect(@project.name).to eq("Gitlab")
118
- expect(@project.owner.name).to eq("John Smith")
119
- end
120
- end
121
-
122
- describe ".create_fork" do
123
- context "without sudo option" do
124
- before do
125
- stub_post("/projects/3/fork", "project_fork")
126
- @project = Gitlab.create_fork(3)
127
- end
128
-
129
- it "should post to the correct resource" do
130
- expect(a_post("/projects/3/fork")).to have_been_made
131
- end
132
-
133
- it "should return information about the forked project" do
134
- expect(@project.forked_from_project.id).to eq(3)
135
- expect(@project.id).to eq(20)
136
- end
137
- end
138
-
139
- context "with the sudo option" do
140
- before do
141
- stub_post("/projects/3/fork", "project_forked_for_user")
142
- @sudoed_username = 'jack.smith'
143
- @project = Gitlab.create_fork(3, sudo: @sudoed_username)
144
- end
145
-
146
- it "should post to the correct resource" do
147
- expect(a_post("/projects/3/fork")).to have_been_made
148
- end
149
-
150
- it "should return information about the forked project" do
151
- expect(@project.forked_from_project.id).to eq(3)
152
- expect(@project.id).to eq(20)
153
- expect(@project.owner.username).to eq(@sudoed_username)
154
- end
155
- end
156
- end
157
-
158
- describe ".team_members" do
159
- before do
160
- stub_get("/projects/3/members", "team_members")
161
- @team_members = Gitlab.team_members(3)
162
- end
163
-
164
- it "should get the correct resource" do
165
- expect(a_get("/projects/3/members")).to have_been_made
166
- end
167
-
168
- it "should return a paginated response of team members" do
169
- expect(@team_members).to be_a Gitlab::PaginatedResponse
170
- expect(@team_members.first.name).to eq("John Smith")
171
- end
172
- end
173
-
174
- describe ".team_member" do
175
- before do
176
- stub_get("/projects/3/members/1", "team_member")
177
- @team_member = Gitlab.team_member(3, 1)
178
- end
179
-
180
- it "should get the correct resource" do
181
- expect(a_get("/projects/3/members/1")).to have_been_made
182
- end
183
-
184
- it "should return information about a team member" do
185
- expect(@team_member.name).to eq("John Smith")
186
- end
187
- end
188
-
189
- describe ".add_team_member" do
190
- before do
191
- stub_post("/projects/3/members", "team_member")
192
- @team_member = Gitlab.add_team_member(3, 1, 40)
193
- end
194
-
195
- it "should get the correct resource" do
196
- expect(a_post("/projects/3/members").
197
- with(body: { user_id: '1', access_level: '40' })).to have_been_made
198
- end
199
-
200
- it "should return information about an added team member" do
201
- expect(@team_member.name).to eq("John Smith")
202
- end
203
- end
204
-
205
- describe ".edit_team_member" do
206
- before do
207
- stub_put("/projects/3/members/1", "team_member")
208
- @team_member = Gitlab.edit_team_member(3, 1, 40)
209
- end
210
-
211
- it "should get the correct resource" do
212
- expect(a_put("/projects/3/members/1").
213
- with(body: { access_level: '40' })).to have_been_made
214
- end
215
-
216
- it "should return information about an edited team member" do
217
- expect(@team_member.name).to eq("John Smith")
218
- end
219
- end
220
-
221
- describe ".remove_team_member" do
222
- before do
223
- stub_delete("/projects/3/members/1", "team_member")
224
- @team_member = Gitlab.remove_team_member(3, 1)
225
- end
226
-
227
- it "should get the correct resource" do
228
- expect(a_delete("/projects/3/members/1")).to have_been_made
229
- end
230
-
231
- it "should return information about a removed team member" do
232
- expect(@team_member.name).to eq("John Smith")
233
- end
234
- end
235
-
236
- describe ".project_hooks" do
237
- before do
238
- stub_get("/projects/1/hooks", "project_hooks")
239
- @hooks = Gitlab.project_hooks(1)
240
- end
241
-
242
- it "should get the correct resource" do
243
- expect(a_get("/projects/1/hooks")).to have_been_made
244
- end
245
-
246
- it "should return a paginated response of hooks" do
247
- expect(@hooks).to be_a Gitlab::PaginatedResponse
248
- expect(@hooks.first.url).to eq("https://api.example.net/v1/webhooks/ci")
249
- end
250
- end
251
-
252
- describe ".project_hook" do
253
- before do
254
- stub_get("/projects/1/hooks/1", "project_hook")
255
- @hook = Gitlab.project_hook(1, 1)
256
- end
257
-
258
- it "should get the correct resource" do
259
- expect(a_get("/projects/1/hooks/1")).to have_been_made
260
- end
261
-
262
- it "should return information about a hook" do
263
- expect(@hook.url).to eq("https://api.example.net/v1/webhooks/ci")
264
- end
265
- end
266
-
267
- describe ".add_project_hook" do
268
- context "without specified events" do
269
- before do
270
- stub_post("/projects/1/hooks", "project_hook")
271
- @hook = Gitlab.add_project_hook(1, "https://api.example.net/v1/webhooks/ci")
272
- end
273
-
274
- it "should get the correct resource" do
275
- body = { url: "https://api.example.net/v1/webhooks/ci" }
276
- expect(a_post("/projects/1/hooks").with(body: body)).to have_been_made
277
- end
278
-
279
- it "should return information about an added hook" do
280
- expect(@hook.url).to eq("https://api.example.net/v1/webhooks/ci")
281
- end
282
- end
283
-
284
- context "with specified events" do
285
- before do
286
- stub_post("/projects/1/hooks", "project_hook")
287
- @hook = Gitlab.add_project_hook(1, "https://api.example.net/v1/webhooks/ci", push_events: true, merge_requests_events: true)
288
- end
289
-
290
- it "should get the correct resource" do
291
- body = { url: "https://api.example.net/v1/webhooks/ci", push_events: "true", merge_requests_events: "true" }
292
- expect(a_post("/projects/1/hooks").with(body: body)).to have_been_made
293
- end
294
-
295
- it "should return information about an added hook" do
296
- expect(@hook.url).to eq("https://api.example.net/v1/webhooks/ci")
297
- end
298
- end
299
- end
300
-
301
- describe ".edit_project_hook" do
302
- before do
303
- stub_put("/projects/1/hooks/1", "project_hook")
304
- @hook = Gitlab.edit_project_hook(1, 1, "https://api.example.net/v1/webhooks/ci")
305
- end
306
-
307
- it "should get the correct resource" do
308
- body = { url: "https://api.example.net/v1/webhooks/ci" }
309
- expect(a_put("/projects/1/hooks/1").with(body: body)).to have_been_made
310
- end
311
-
312
- it "should return information about an edited hook" do
313
- expect(@hook.url).to eq("https://api.example.net/v1/webhooks/ci")
314
- end
315
- end
316
-
317
- describe ".edit_project" do
318
- context "using project ID" do
319
- before do
320
- stub_put("/projects/3", "project_edit").with(body: { name: "Gitlab-edit" })
321
- @edited_project = Gitlab.edit_project(3, name: "Gitlab-edit")
322
- end
323
-
324
- it "should get the correct resource" do
325
- expect(a_put("/projects/3").with(body: { name: "Gitlab-edit" })).to have_been_made
326
- end
327
-
328
- it "should return information about an edited project" do
329
- expect(@edited_project.name).to eq("Gitlab-edit")
330
- end
331
- end
332
-
333
- context "using namespaced project path" do
334
- it "encodes the path properly" do
335
- stub = stub_put("/projects/namespace%2Fpath", "project_edit").with(body: { name: "Gitlab-edit" })
336
- Gitlab.edit_project('namespace/path', name: "Gitlab-edit")
337
- expect(stub).to have_been_requested
338
- end
339
- end
340
- end
341
-
342
- describe ".delete_project_hook" do
343
- context "when empty response" do
344
- before do
345
- stub_request(:delete, "#{Gitlab.endpoint}/projects/1/hooks/1").
346
- with(headers: { 'PRIVATE-TOKEN' => Gitlab.private_token }).
347
- to_return(body: '')
348
- @hook = Gitlab.delete_project_hook(1, 1)
349
- end
350
-
351
- it "should get the correct resource" do
352
- expect(a_delete("/projects/1/hooks/1")).to have_been_made
353
- end
354
-
355
- it "should return false" do
356
- expect(@hook).to be(false)
357
- end
358
- end
359
-
360
- context "when JSON response" do
361
- before do
362
- stub_delete("/projects/1/hooks/1", "project_hook")
363
- @hook = Gitlab.delete_project_hook(1, 1)
364
- end
365
-
366
- it "should get the correct resource" do
367
- expect(a_delete("/projects/1/hooks/1")).to have_been_made
368
- end
369
-
370
- it "should return information about a deleted hook" do
371
- expect(@hook.url).to eq("https://api.example.net/v1/webhooks/ci")
372
- end
373
- end
374
- end
375
-
376
- describe ".push_rule" do
377
- before do
378
- stub_get("/projects/1/push_rule", "push_rule")
379
- @push_rule = Gitlab.push_rule(1)
380
- end
381
-
382
- it "should get the correct resource" do
383
- expect(a_get("/projects/1/push_rule")).to have_been_made
384
- end
385
-
386
- it "should return information about a push rule" do
387
- expect(@push_rule.commit_message_regex).to eq("\\b[A-Z]{3}-[0-9]+\\b")
388
- end
389
- end
390
-
391
- describe ".add_push_rule" do
392
- before do
393
- stub_post("/projects/1/push_rule", "push_rule")
394
- @push_rule = Gitlab.add_push_rule(1, { deny_delete_tag: false, commit_message_regex: "\\b[A-Z]{3}-[0-9]+\\b" })
395
- end
396
-
397
- it "should get the correct resource" do
398
- expect(a_post("/projects/1/push_rule")).to have_been_made
399
- end
400
-
401
- it "should return information about an added push rule" do
402
- expect(@push_rule.commit_message_regex).to eq("\\b[A-Z]{3}-[0-9]+\\b")
403
- end
404
- end
405
-
406
- describe ".edit_push_rule" do
407
- before do
408
- stub_put("/projects/1/push_rule", "push_rule")
409
- @push_rule = Gitlab.edit_push_rule(1, { deny_delete_tag: false, commit_message_regex: "\\b[A-Z]{3}-[0-9]+\\b" })
410
- end
411
-
412
- it "should get the correct resource" do
413
- expect(a_put("/projects/1/push_rule")).to have_been_made
414
- end
415
-
416
- it "should return information about an edited push rule" do
417
- expect(@push_rule.commit_message_regex).to eq("\\b[A-Z]{3}-[0-9]+\\b")
418
- end
419
- end
420
-
421
- describe ".delete_push_rule" do
422
- context "when empty response" do
423
- before do
424
- stub_request(:delete, "#{Gitlab.endpoint}/projects/1/push_rule").
425
- with(headers: { 'PRIVATE-TOKEN' => Gitlab.private_token }).
426
- to_return(body: '')
427
- @push_rule = Gitlab.delete_push_rule(1)
428
- end
429
-
430
- it "should get the correct resource" do
431
- expect(a_delete("/projects/1/push_rule")).to have_been_made
432
- end
433
-
434
- it "should return false" do
435
- expect(@push_rule).to be(false)
436
- end
437
- end
438
-
439
- context "when JSON response" do
440
- before do
441
- stub_delete("/projects/1/push_rule", "push_rule")
442
- @push_rule = Gitlab.delete_push_rule(1)
443
- end
444
-
445
- it "should get the correct resource" do
446
- expect(a_delete("/projects/1/push_rule")).to have_been_made
447
- end
448
-
449
- it "should return information about a deleted push rule" do
450
- expect(@push_rule.commit_message_regex).to eq("\\b[A-Z]{3}-[0-9]+\\b")
451
- end
452
- end
453
- end
454
-
455
- describe ".make_forked_from" do
456
- before do
457
- stub_post("/projects/42/fork/24", "project_fork_link")
458
- @forked_project_link = Gitlab.make_forked_from(42, 24)
459
- end
460
-
461
- it "should get the correct resource" do
462
- expect(a_post("/projects/42/fork/24")).to have_been_made
463
- end
464
-
465
- it "should return information about a forked project" do
466
- expect(@forked_project_link.forked_from_project_id).to eq(24)
467
- expect(@forked_project_link.forked_to_project_id).to eq(42)
468
- end
469
- end
470
-
471
- describe ".remove_forked" do
472
- before do
473
- stub_delete("/projects/42/fork", "project_fork_link")
474
- @forked_project_link = Gitlab.remove_forked(42)
475
- end
476
-
477
- it "should be sent to correct resource" do
478
- expect(a_delete("/projects/42/fork")).to have_been_made
479
- end
480
-
481
- it "should return information about an unforked project" do
482
- expect(@forked_project_link.forked_to_project_id).to eq(42)
483
- end
484
- end
485
-
486
- describe ".deploy_keys" do
487
- before do
488
- stub_get("/projects/42/deploy_keys", "project_keys")
489
- @deploy_keys = Gitlab.deploy_keys(42)
490
- end
491
-
492
- it "should get the correct resource" do
493
- expect(a_get("/projects/42/deploy_keys")).to have_been_made
494
- end
495
-
496
- it "should return project deploy keys" do
497
- expect(@deploy_keys).to be_a Gitlab::PaginatedResponse
498
- expect(@deploy_keys.first.id).to eq 2
499
- expect(@deploy_keys.first.title).to eq "Key Title"
500
- expect(@deploy_keys.first.key).to match(/ssh-rsa/)
501
- end
502
- end
503
-
504
- describe ".deploy_key" do
505
- before do
506
- stub_get("/projects/42/deploy_keys/2", "project_key")
507
- @deploy_key = Gitlab.deploy_key(42, 2)
508
- end
509
-
510
- it "should get the correct resource" do
511
- expect(a_get("/projects/42/deploy_keys/2")).to have_been_made
512
- end
513
-
514
- it "should return project deploy key" do
515
- expect(@deploy_key.id).to eq 2
516
- expect(@deploy_key.title).to eq "Key Title"
517
- expect(@deploy_key.key).to match(/ssh-rsa/)
518
- end
519
- end
520
-
521
- describe ".delete_deploy_key" do
522
- before do
523
- stub_delete("/projects/42/deploy_keys/2", "project_key")
524
- @deploy_key = Gitlab.delete_deploy_key(42, 2)
525
- end
526
-
527
- it "should get the correct resource" do
528
- expect(a_delete("/projects/42/deploy_keys/2")).to have_been_made
529
- end
530
-
531
- it "should return information about a deleted key" do
532
- expect(@deploy_key.id).to eq(2)
533
- end
534
- end
535
-
536
- describe ".enable_deploy_key" do
537
- before do
538
- stub_post("/projects/42/deploy_keys/2/enable", "project_key")
539
- @deploy_key = Gitlab.enable_deploy_key(42, 2)
540
- end
541
-
542
- it "should get the correct resource" do
543
- expect(a_post("/projects/42/deploy_keys/2/enable").
544
- with(body: { id: '42', key_id: '2' })).to have_been_made
545
- end
546
-
547
- it "should return information about an enabled key" do
548
- expect(@deploy_key.id).to eq(2)
549
- end
550
- end
551
-
552
- describe ".disable_deploy_key" do
553
- before do
554
- stub_post("/projects/42/deploy_keys/2/disable", "project_key")
555
- @deploy_key = Gitlab.disable_deploy_key(42, 2)
556
- end
557
-
558
- it "should get the correct resource" do
559
- expect(a_post("/projects/42/deploy_keys/2/disable").
560
- with(body: { id: '42', key_id: '2' })).to have_been_made
561
- end
562
-
563
- it "should return information about a disabled key" do
564
- expect(@deploy_key.id).to eq(2)
565
- end
566
- end
567
-
568
- describe ".share_project_with_group" do
569
- before do
570
- stub_post("/projects/3/share", "group")
571
- @group = Gitlab.share_project_with_group(3, 10, 40)
572
- end
573
-
574
- it "should get the correct resource" do
575
- expect(a_post("/projects/3/share").
576
- with(body: { group_id: '10', group_access: '40' })).to have_been_made
577
- end
578
-
579
- it "should return information about an added group" do
580
- expect(@group.id).to eq(10)
581
- end
582
- end
583
-
584
- describe ".star_project" do
585
- before do
586
- stub_post("/projects/3/star", "project_star")
587
- @starred_project = Gitlab.star_project(3)
588
- end
589
-
590
- it "should get the correct resource" do
591
- expect(a_post("/projects/3/star")).to have_been_made
592
- end
593
-
594
- it "should return information about the starred project" do
595
- expect(@starred_project.id).to eq(3)
596
- end
597
- end
598
-
599
- describe ".unstar_project" do
600
- before do
601
- stub_delete("/projects/3/star", "project_unstar")
602
- @unstarred_project = Gitlab.unstar_project(3)
603
- end
604
-
605
- it "should get the correct resource" do
606
- expect(a_delete("/projects/3/star")).to have_been_made
607
- end
608
-
609
- it "should return information about the unstarred project" do
610
- expect(@unstarred_project.id).to eq(3)
611
- end
612
- end
613
- end
@@ -1,94 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Gitlab::Client do
4
- it { should respond_to :repo_tags }
5
- it { should respond_to :repo_create_tag }
6
- it { should respond_to :repo_branches }
7
- it { should respond_to :repo_branch }
8
- it { should respond_to :repo_tree }
9
- it { should respond_to :repo_compare }
10
-
11
- describe ".tags" do
12
- before do
13
- stub_get("/projects/3/repository/tags", "project_tags")
14
- @tags = Gitlab.tags(3)
15
- end
16
-
17
- it "should get the correct resource" do
18
- expect(a_get("/projects/3/repository/tags")).to have_been_made
19
- end
20
-
21
- it "should return a paginated response of repository tags" do
22
- expect(@tags).to be_a Gitlab::PaginatedResponse
23
- expect(@tags.first.name).to eq("v2.8.2")
24
- end
25
- end
26
-
27
- describe ".create_tag" do
28
- context "when lightweight" do
29
- before do
30
- stub_post("/projects/3/repository/tags", "project_tag_lightweight")
31
- @tag = Gitlab.create_tag(3, 'v1.0.0', '2695effb5807a22ff3d138d593fd856244e155e7')
32
- end
33
-
34
- it "should get the correct resource" do
35
- expect(a_post("/projects/3/repository/tags")).to have_been_made
36
- end
37
-
38
- it "should return information about a new repository tag" do
39
- expect(@tag.name).to eq("v1.0.0")
40
- expect(@tag.message).to eq(nil)
41
- end
42
- end
43
-
44
- context "when annotated" do
45
- before do
46
- stub_post("/projects/3/repository/tags", "project_tag_annotated")
47
- @tag = Gitlab.create_tag(3, 'v1.1.0', '2695effb5807a22ff3d138d593fd856244e155e7', 'Release 1.1.0')
48
- end
49
-
50
- it "should get the correct resource" do
51
- expect(a_post("/projects/3/repository/tags")).to have_been_made
52
- end
53
-
54
- it "should return information about a new repository tag" do
55
- expect(@tag.name).to eq("v1.1.0")
56
- expect(@tag.message).to eq("Release 1.1.0")
57
- end
58
- end
59
- end
60
-
61
- describe ".tree" do
62
- before do
63
- stub_get("/projects/3/repository/tree", "tree")
64
- @tree = Gitlab.tree(3)
65
- end
66
-
67
- it "should get the correct resource" do
68
- expect(a_get("/projects/3/repository/tree")).to have_been_made
69
- end
70
-
71
- it "should return a paginated response of repository tree files (root level)" do
72
- expect(@tree).to be_a Gitlab::PaginatedResponse
73
- expect(@tree.first.name).to eq("app")
74
- end
75
- end
76
-
77
- describe ".compare" do
78
- before do
79
- stub_get("/projects/3/repository/compare", "compare_merge_request_diff").
80
- with(query: { from: "master", to: "feature" })
81
- @diff = Gitlab.compare(3, 'master', 'feature')
82
- end
83
-
84
- it "should get the correct resource" do
85
- expect(a_get("/projects/3/repository/compare").
86
- with(query: { from: "master", to: "feature" })).to have_been_made
87
- end
88
-
89
- it "should get diffs of a merge request" do
90
- expect(@diff.diffs).to be_kind_of Array
91
- expect(@diff.diffs.last["new_path"]).to eq "files/js/application.js"
92
- end
93
- end
94
- end