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,418 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Gitlab::Client do
4
- describe ".users" do
5
- before do
6
- stub_get("/users", "users")
7
- @users = Gitlab.users
8
- end
9
-
10
- it "should get the correct resource" do
11
- expect(a_get("/users")).to have_been_made
12
- end
13
-
14
- it "should return a paginated response of users" do
15
- expect(@users).to be_a Gitlab::PaginatedResponse
16
- expect(@users.first.email).to eq("john@example.com")
17
- end
18
- end
19
-
20
- describe ".user" do
21
- context "with user ID passed" do
22
- before do
23
- stub_get("/users/1", "user")
24
- @user = Gitlab.user(1)
25
- end
26
-
27
- it "should get the correct resource" do
28
- expect(a_get("/users/1")).to have_been_made
29
- end
30
-
31
- it "should return information about a user" do
32
- expect(@user.email).to eq("john@example.com")
33
- end
34
- end
35
-
36
- context "without user ID passed" do
37
- before do
38
- stub_get("/user", "user")
39
- @user = Gitlab.user
40
- end
41
-
42
- it "should get the correct resource" do
43
- expect(a_get("/user")).to have_been_made
44
- end
45
-
46
- it "should return information about an authorized user" do
47
- expect(@user.email).to eq("john@example.com")
48
- end
49
- end
50
- end
51
-
52
- describe ".create_user" do
53
- context "when successful request" do
54
- before do
55
- stub_post("/users", "user")
56
- @user = Gitlab.create_user("email", "pass")
57
- end
58
-
59
- it "should get the correct resource" do
60
- body = { email: "email", password: "pass", name: "email" }
61
- expect(a_post("/users").with(body: body)).to have_been_made
62
- end
63
-
64
- it "should return information about a created user" do
65
- expect(@user.email).to eq("john@example.com")
66
- end
67
- end
68
-
69
- context "when bad request" do
70
- it "should throw an exception" do
71
- stub_post("/users", "error_already_exists", 409)
72
- expect do
73
- Gitlab.create_user("email", "pass")
74
- end.to raise_error(Gitlab::Error::Conflict, "Server responded with code 409, message: 409 Already exists. Request URI: #{Gitlab.endpoint}/users")
75
- end
76
- end
77
- end
78
-
79
- describe ".create_user_with_userame" do
80
- context "when successful request" do
81
- before do
82
- stub_post("/users", "user")
83
- @user = Gitlab.create_user("email", "pass", "username")
84
- end
85
-
86
- it "should get the correct resource" do
87
- body = { email: "email", password: "pass", username: "username" }
88
- expect(a_post("/users").with(body: body)).to have_been_made
89
- end
90
-
91
- it "should return information about a created user" do
92
- expect(@user.email).to eq("john@example.com")
93
- end
94
- end
95
-
96
- context "when bad request" do
97
- it "should throw an exception" do
98
- stub_post("/users", "error_already_exists", 409)
99
- expect do
100
- Gitlab.create_user("email", "pass", "username")
101
- end.to raise_error(Gitlab::Error::Conflict, "Server responded with code 409, message: 409 Already exists. Request URI: #{Gitlab.endpoint}/users")
102
- end
103
- end
104
- end
105
-
106
- describe ".edit_user" do
107
- before do
108
- @options = { name: "Roberto" }
109
- stub_put("/users/1", "user").with(body: @options)
110
- @user = Gitlab.edit_user(1, @options)
111
- end
112
-
113
- it "should get the correct resource" do
114
- expect(a_put("/users/1").with(body: @options)).to have_been_made
115
- end
116
- end
117
-
118
- describe ".delete_user" do
119
- before do
120
- stub_delete("/users/1", "user")
121
- @user = Gitlab.delete_user(1)
122
- end
123
-
124
- it "should get the correct resource" do
125
- expect(a_delete("/users/1")).to have_been_made
126
- end
127
-
128
- it "should return information about a deleted user" do
129
- expect(@user.email).to eq("john@example.com")
130
- end
131
- end
132
-
133
- describe ".block_user" do
134
- before do
135
- stub_post("/users/1/block", "user_block_unblock")
136
- @result = Gitlab.block_user(1)
137
- end
138
-
139
- it "should get the correct resource" do
140
- expect(a_post("/users/1/block")).to have_been_made
141
- end
142
-
143
- it "should return boolean" do
144
- expect(@result).to eq(true)
145
- end
146
- end
147
-
148
- describe ".unblock_user" do
149
- before do
150
- stub_post("/users/1/unblock", "user_block_unblock")
151
- @result = Gitlab.unblock_user(1)
152
- end
153
-
154
- it "should get the correct resource" do
155
- expect(a_post("/users/1/unblock")).to have_been_made
156
- end
157
-
158
- it "should return boolean" do
159
- expect(@result).to eq(true)
160
- end
161
- end
162
-
163
- describe ".session" do
164
- after do
165
- Gitlab.endpoint = 'https://api.example.com'
166
- Gitlab.private_token = 'secret'
167
- end
168
-
169
- before do
170
- stub_request(:post, "#{Gitlab.endpoint}/session").
171
- to_return(body: load_fixture('session'), status: 200)
172
- @session = Gitlab.session("email", "pass")
173
- end
174
-
175
- context "when endpoint is not set" do
176
- it "should raise Error::MissingCredentials" do
177
- Gitlab.endpoint = nil
178
- expect do
179
- Gitlab.session("email", "pass")
180
- end.to raise_error(Gitlab::Error::MissingCredentials, 'Please set an endpoint to API')
181
- end
182
- end
183
-
184
- context "when private_token is not set" do
185
- it "should not raise Error::MissingCredentials" do
186
- Gitlab.private_token = nil
187
- expect { Gitlab.session("email", "pass") }.to_not raise_error
188
- end
189
- end
190
-
191
- context "when endpoint is set" do
192
- it "should get the correct resource" do
193
- expect(a_request(:post, "#{Gitlab.endpoint}/session")).to have_been_made
194
- end
195
-
196
- it "should return information about a created session" do
197
- expect(@session.email).to eq("john@example.com")
198
- expect(@session.private_token).to eq("qEsq1pt6HJPaNciie3MG")
199
- end
200
- end
201
- end
202
-
203
- describe ".ssh_keys" do
204
- context "with user ID passed" do
205
- before do
206
- stub_get("/users/1/keys", "keys")
207
- @keys = Gitlab.ssh_keys({ user_id: 1 })
208
- end
209
-
210
- it "should get the correct resource" do
211
- expect(a_get("/users/1/keys")).to have_been_made
212
- end
213
-
214
- it "should return a paginated response of SSH keys" do
215
- expect(@keys).to be_a Gitlab::PaginatedResponse
216
- expect(@keys.first.title).to eq("narkoz@helium")
217
- end
218
- end
219
-
220
- context "without user ID passed" do
221
- before do
222
- stub_get("/user/keys", "keys")
223
- @keys = Gitlab.ssh_keys
224
- end
225
-
226
- it "should get the correct resource" do
227
- expect(a_get("/user/keys")).to have_been_made
228
- end
229
-
230
- it "should return a paginated response of SSH keys" do
231
- expect(@keys).to be_a Gitlab::PaginatedResponse
232
- expect(@keys.first.title).to eq("narkoz@helium")
233
- end
234
- end
235
- end
236
-
237
- describe ".ssh_key" do
238
- before do
239
- stub_get("/user/keys/1", "key")
240
- @key = Gitlab.ssh_key(1)
241
- end
242
-
243
- it "should get the correct resource" do
244
- expect(a_get("/user/keys/1")).to have_been_made
245
- end
246
-
247
- it "should return information about an SSH key" do
248
- expect(@key.title).to eq("narkoz@helium")
249
- end
250
- end
251
-
252
- describe ".create_ssh_key" do
253
- before do
254
- stub_post("/user/keys", "key")
255
- @key = Gitlab.create_ssh_key("title", "body")
256
- end
257
-
258
- it "should get the correct resource" do
259
- body = { title: "title", key: "body" }
260
- expect(a_post("/user/keys").with(body: body)).to have_been_made
261
- end
262
-
263
- it "should return information about a created SSH key" do
264
- expect(@key.title).to eq("narkoz@helium")
265
- end
266
- end
267
-
268
- describe ".delete_ssh_key" do
269
- before do
270
- stub_delete("/user/keys/1", "key")
271
- @key = Gitlab.delete_ssh_key(1)
272
- end
273
-
274
- it "should get the correct resource" do
275
- expect(a_delete("/user/keys/1")).to have_been_made
276
- end
277
-
278
- it "should return information about a deleted SSH key" do
279
- expect(@key.title).to eq("narkoz@helium")
280
- end
281
- end
282
-
283
- describe ".emails" do
284
- describe "without user ID" do
285
- before do
286
- stub_get("/user/emails", "user_emails")
287
- @emails = Gitlab.emails
288
- end
289
-
290
- it "should get the correct resource" do
291
- expect(a_get("/user/emails")).to have_been_made
292
- end
293
-
294
- it "should return a information about a emails of user" do
295
- email = @emails.first
296
- expect(email.id).to eq 1
297
- expect(email.email).to eq("email@example.com")
298
- end
299
- end
300
-
301
- describe "with user ID" do
302
- before do
303
- stub_get("/users/2/emails", "user_emails")
304
- @emails = Gitlab.emails(2)
305
- end
306
-
307
- it "should get the correct resource" do
308
- expect(a_get("/users/2/emails")).to have_been_made
309
- end
310
-
311
- it "should return a information about a emails of user" do
312
- email = @emails.first
313
- expect(email.id).to eq 1
314
- expect(email.email).to eq("email@example.com")
315
- end
316
- end
317
- end
318
-
319
- describe ".email" do
320
- before do
321
- stub_get("/user/emails/2", "user_email")
322
- @email = Gitlab.email(2)
323
- end
324
-
325
- it "should get the correct resource" do
326
- expect(a_get("/user/emails/2")).to have_been_made
327
- end
328
-
329
- it "should return a information about a email of user" do
330
- expect(@email.id).to eq 1
331
- expect(@email.email).to eq("email@example.com")
332
- end
333
- end
334
-
335
- describe ".add_email" do
336
- describe "without user ID" do
337
- before do
338
- stub_post("/user/emails", "user_email")
339
- @email = Gitlab.add_email("email@example.com")
340
- end
341
-
342
- it "should get the correct resource" do
343
- body = { email: "email@example.com" }
344
- expect(a_post("/user/emails").with(body: body)).to have_been_made
345
- end
346
-
347
- it "should return information about a new email" do
348
- expect(@email.id).to eq(1)
349
- expect(@email.email).to eq("email@example.com")
350
- end
351
- end
352
-
353
- describe "with user ID" do
354
- before do
355
- stub_post("/users/2/emails", "user_email")
356
- @email = Gitlab.add_email("email@example.com", 2)
357
- end
358
-
359
- it "should get the correct resource" do
360
- body = { email: "email@example.com" }
361
- expect(a_post("/users/2/emails").with(body: body)).to have_been_made
362
- end
363
-
364
- it "should return information about a new email" do
365
- expect(@email.id).to eq(1)
366
- expect(@email.email).to eq("email@example.com")
367
- end
368
- end
369
- end
370
-
371
- describe ".delete_email" do
372
- describe "without user ID" do
373
- before do
374
- stub_delete("/user/emails/1", "user_email")
375
- @email = Gitlab.delete_email(1)
376
- end
377
-
378
- it "should get the correct resource" do
379
- expect(a_delete("/user/emails/1")).to have_been_made
380
- end
381
-
382
- it "should return information about a deleted email" do
383
- expect(@email).to be_truthy
384
- end
385
- end
386
-
387
- describe "with user ID" do
388
- before do
389
- stub_delete("/users/2/emails/1", "user_email")
390
- @email = Gitlab.delete_email(1, 2)
391
- end
392
-
393
- it "should get the correct resource" do
394
- expect(a_delete("/users/2/emails/1")).to have_been_made
395
- end
396
-
397
- it "should return information about a deleted email" do
398
- expect(@email).to be_truthy
399
- end
400
- end
401
- end
402
-
403
- describe ".user_search" do
404
- before do
405
- stub_get("/users?search=User", "user_search")
406
- @users = Gitlab.user_search('User')
407
- end
408
-
409
- it "should get the correct resource" do
410
- expect(a_get("/users?search=User")).to have_been_made
411
- end
412
-
413
- it "should return an array of users found" do
414
- expect(@users.first.id).to eq(1)
415
- expect(@users.last.id).to eq(2)
416
- end
417
- end
418
- end
@@ -1,45 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe Gitlab::Error do
4
- describe "#handle_message" do
5
- require "stringio"
6
-
7
- before do
8
- request_object = HTTParty::Request.new(Net::HTTP::Get, '/')
9
- response_object = Net::HTTPOK.new('1.1', 200, 'OK')
10
- body = StringIO.new("{foo:'bar'}")
11
- def body.message; self.string; end
12
-
13
- parsed_response = lambda { body }
14
- response_object['last-modified'] = Date.new(2010, 1, 15).to_s
15
- response_object['content-length'] = "1024"
16
-
17
- response = HTTParty::Response.new(request_object, response_object, parsed_response, body: body)
18
- @error = Gitlab::Error::ResponseError.new(response)
19
-
20
- @array = Array.new(['First message.', 'Second message.'])
21
- @obj_h = Gitlab::ObjectifiedHash.new(user: ['not set'],
22
- password: ['too short'],
23
- embed_entity: { foo: ['bar'], sna: ['fu'] })
24
- end
25
-
26
- context "when passed an ObjectifiedHash" do
27
- it "should return a joined string of error messages sorted by key" do
28
- expect(@error.send(:handle_message, @obj_h)).to eq("'embed_entity' (foo: bar) (sna: fu), 'password' too short, 'user' not set")
29
- end
30
- end
31
-
32
- context "when passed an Array" do
33
- it "should return a joined string of messages" do
34
- expect(@error.send(:handle_message, @array)).to eq("First message. Second message.")
35
- end
36
- end
37
-
38
- context "when passed a String" do
39
- it "should return the String untouched" do
40
- error = 'this is an error string'
41
- expect(@error.send(:handle_message, error)).to eq('this is an error string')
42
- end
43
- end
44
- end
45
- end
@@ -1,33 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Gitlab::FileResponse do
4
- before do
5
- @file_response = Gitlab::FileResponse.new StringIO.new("", 'rb+')
6
- end
7
-
8
- context '.empty?' do
9
- it "shoudl return false" do
10
- expect(@file_response.empty?).to be false
11
- end
12
- end
13
-
14
- context '.to_hash' do
15
- it "should have `filename` key and `data` key" do
16
- h = @file_response.to_hash
17
- expect(h.has_key?(:filename)).to be_truthy
18
- expect(h.has_key?(:data)).to be_truthy
19
- end
20
- end
21
-
22
- context '.parse_headers!' do
23
- it "should parse headers" do
24
- @file_response.parse_headers!('Content-Disposition' => 'attachment; filename=artifacts.zip')
25
- expect(@file_response.filename).to eq "artifacts.zip"
26
- end
27
-
28
- it "should handle quoted filenames" do
29
- @file_response.parse_headers!('Content-Disposition' => 'attachment; filename="artifacts.zip"')
30
- expect(@file_response.filename).to eq "artifacts.zip"
31
- end
32
- end
33
- end
@@ -1,46 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Gitlab::Help do
4
- describe ".ri_cmd" do
5
- context "ri command found" do
6
- it "should return the path to RI" do
7
- allow(Gitlab::Help).to receive(:`).with(/which ri/).and_return('/usr/bin/ri')
8
- expect(Gitlab::Help.ri_cmd).to eq('/usr/bin/ri')
9
- end
10
- end
11
-
12
- context "ri command NOT found" do
13
- it "should raise" do
14
- allow(Gitlab::Help).to receive(:`).with(/which ri/).and_return('')
15
- expect { Gitlab::Help.ri_cmd }.to raise_error RuntimeError
16
- end
17
- end
18
- end
19
-
20
- describe ".change_help_output!" do
21
- before do
22
- @cmd = "create_branch"
23
- @help_output = "Gitlab.#{@cmd}(4, 'new-branch', 'master')"
24
- @help_output_with_options = "Gitlab.groups({ per_page: 3 })"
25
- end
26
- it "should return a String of modified output" do
27
- Gitlab::Help.change_help_output! @cmd, @help_output
28
- expect(@help_output).to eq("Gitlab.create_branch 4 'new-branch' 'master'")
29
- end
30
- it "should format options hash and return a String of modified output" do
31
- Gitlab::Help.change_help_output! 'groups', @help_output_with_options
32
- expect(@help_output_with_options).to eq("Gitlab.groups \"{ per_page: 3 }\"")
33
- end
34
- end
35
-
36
- describe ".namespace" do
37
- before do
38
- @cmd = 'create_tag'
39
- @namespace = Gitlab::Help.namespace @cmd
40
- end
41
- it "should return the full namespace for a command" do
42
- expect(@namespace).to be_a String
43
- expect(@namespace).to eq("Gitlab::Client::Tags.#{@cmd}")
44
- end
45
- end
46
- end
@@ -1,48 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Gitlab::ObjectifiedHash do
4
- before do
5
- @hash = { a: 1, b: 2, 'string' => 'string', symbol: :symbol }
6
- @oh = Gitlab::ObjectifiedHash.new @hash
7
- end
8
-
9
- it "should objectify hash" do
10
- expect(@oh.a).to eq(@hash[:a])
11
- expect(@oh.b).to eq(@hash[:b])
12
- end
13
-
14
- describe "#to_hash" do
15
- it "should return an original hash" do
16
- expect(@oh.to_hash).to eq(@hash)
17
- end
18
-
19
- it "should have an alias #to_h" do
20
- expect(@oh.respond_to?(:to_h)).to be_truthy
21
- end
22
- end
23
-
24
- describe "#inspect" do
25
- it "should return a formatted string" do
26
- pretty_string = "#<#{@oh.class.name}:#{@oh.object_id} {hash: #{@hash}}"
27
- expect(@oh.inspect).to eq(pretty_string)
28
- end
29
- end
30
-
31
- describe "#respond_to" do
32
- it "should return true for methods this object responds to through method_missing as sym" do
33
- expect(@oh.respond_to?(:a)).to be_truthy
34
- end
35
-
36
- it "should return true for methods this object responds to through method_missing as string" do
37
- expect(@oh.respond_to?('string')).to be_truthy
38
- end
39
-
40
- it "should not care if you use a string or symbol to reference a method" do
41
- expect(@oh.respond_to?(:string)).to be_truthy
42
- end
43
-
44
- it "should not care if you use a string or symbol to reference a method" do
45
- expect(@oh.respond_to?('symbol')).to be_truthy
46
- end
47
- end
48
- end
@@ -1,16 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Gitlab::PageLinks do
4
- before do
5
- @page_links = Gitlab::PageLinks.new('Link' => "<http://example.com/api/v3/projects?page=1&per_page=5>; rel=\"first\", <http://example.com/api/v3/projects?page=20&per_page=5>; rel=\"last\", <http://example.com/api/v3/projects?page=7&per_page=5>; rel=\"prev\", <http://example.com/api/v3/projects?page=9&per_page=5>; rel=\"next\"")
6
- end
7
-
8
- context '.extract_links' do
9
- it 'should extract link header appropriately' do
10
- expect(@page_links.last).to eql 'http://example.com/api/v3/projects?page=20&per_page=5'
11
- expect(@page_links.first).to eql 'http://example.com/api/v3/projects?page=1&per_page=5'
12
- expect(@page_links.next).to eql 'http://example.com/api/v3/projects?page=9&per_page=5'
13
- expect(@page_links.prev).to eql 'http://example.com/api/v3/projects?page=7&per_page=5'
14
- end
15
- end
16
- end
@@ -1,60 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Gitlab::PaginatedResponse do
4
- before do
5
- array = [1, 2, 3, 4]
6
- @paginated_response = Gitlab::PaginatedResponse.new array
7
- end
8
-
9
- it "should respond to *_page and has_*_page methods" do
10
- expect(@paginated_response).to respond_to :first_page
11
- expect(@paginated_response).to respond_to :last_page
12
- expect(@paginated_response).to respond_to :next_page
13
- expect(@paginated_response).to respond_to :prev_page
14
- expect(@paginated_response).to respond_to :has_first_page?
15
- expect(@paginated_response).to respond_to :has_last_page?
16
- expect(@paginated_response).to respond_to :has_next_page?
17
- expect(@paginated_response).to respond_to :has_prev_page?
18
- end
19
-
20
- context '.parse_headers!' do
21
- it "should parse headers" do
22
- @paginated_response.parse_headers!('Link' => "<http://example.com/api/v3/projects?page=1&per_page=5>; rel=\"first\", <http://example.com/api/v3/projects?page=20&per_page=5>; rel=\"last\"")
23
- client = @paginated_response.client = double('client')
24
- first_page_response = double('first_page_response')
25
- last_page_response = double('last_page_response')
26
- allow(client).to receive(:endpoint).and_return("http://example.com/api/v3")
27
- allow(client).to receive(:get).with("/projects?page=1&per_page=5").and_return(first_page_response)
28
- allow(client).to receive(:get).with("/projects?page=20&per_page=5").and_return(last_page_response)
29
- expect(@paginated_response.has_first_page?).to be true
30
- expect(@paginated_response.has_last_page?).to be true
31
- expect(@paginated_response.has_next_page?).to be false
32
- expect(@paginated_response.has_prev_page?).to be false
33
- expect(@paginated_response.first_page).to be first_page_response
34
- expect(@paginated_response.last_page).to be last_page_response
35
- expect(@paginated_response.next_page).to be_nil
36
- expect(@paginated_response.prev_page).to be_nil
37
- end
38
- end
39
-
40
- context '.each_page' do
41
- it "should iterate pages" do
42
- next_page = double('next_page')
43
- allow(@paginated_response).to receive(:has_next_page?).and_return(true)
44
- allow(@paginated_response).to receive(:next_page).and_return(next_page)
45
- allow(next_page).to receive(:has_next_page?).and_return(false)
46
- expect { |b| @paginated_response.each_page(&b) }.to yield_successive_args(@paginated_response, next_page)
47
- end
48
- end
49
-
50
- context '.auto_paginate' do
51
- it "should returns an array if block is not given" do
52
- next_page = double('next_page')
53
- allow(@paginated_response).to receive(:has_next_page?).and_return(true)
54
- allow(@paginated_response).to receive(:next_page).and_return(next_page)
55
- allow(next_page).to receive(:has_next_page?).and_return(false)
56
- allow(next_page).to receive(:to_ary).and_return([5, 6, 7, 8])
57
- expect(@paginated_response.auto_paginate).to contain_exactly(1, 2, 3, 4, 5, 6, 7, 8)
58
- end
59
- end
60
- end