gitlab-akerl 4.0.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 (201) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +20 -0
  3. data/.prospectus +11 -0
  4. data/.travis.yml +8 -0
  5. data/CHANGELOG.md +229 -0
  6. data/CONTRIBUTING.md +195 -0
  7. data/Gemfile +4 -0
  8. data/LICENSE.txt +24 -0
  9. data/README.md +192 -0
  10. data/Rakefile +9 -0
  11. data/bin/console +10 -0
  12. data/bin/setup +6 -0
  13. data/exe/gitlab +7 -0
  14. data/gitlab-akerl.gemspec +31 -0
  15. data/lib/gitlab.rb +45 -0
  16. data/lib/gitlab/api.rb +19 -0
  17. data/lib/gitlab/cli.rb +89 -0
  18. data/lib/gitlab/cli_helpers.rb +241 -0
  19. data/lib/gitlab/client.rb +48 -0
  20. data/lib/gitlab/client/branches.rb +91 -0
  21. data/lib/gitlab/client/build_triggers.rb +51 -0
  22. data/lib/gitlab/client/build_variables.rb +66 -0
  23. data/lib/gitlab/client/builds.rb +106 -0
  24. data/lib/gitlab/client/commits.rb +121 -0
  25. data/lib/gitlab/client/groups.rb +144 -0
  26. data/lib/gitlab/client/issues.rb +113 -0
  27. data/lib/gitlab/client/labels.rb +57 -0
  28. data/lib/gitlab/client/merge_requests.rb +168 -0
  29. data/lib/gitlab/client/milestones.rb +78 -0
  30. data/lib/gitlab/client/namespaces.rb +20 -0
  31. data/lib/gitlab/client/notes.rb +161 -0
  32. data/lib/gitlab/client/pipelines.rb +68 -0
  33. data/lib/gitlab/client/projects.rb +471 -0
  34. data/lib/gitlab/client/repositories.rb +78 -0
  35. data/lib/gitlab/client/repository_files.rb +88 -0
  36. data/lib/gitlab/client/runners.rb +115 -0
  37. data/lib/gitlab/client/services.rb +50 -0
  38. data/lib/gitlab/client/snippets.rb +91 -0
  39. data/lib/gitlab/client/system_hooks.rb +59 -0
  40. data/lib/gitlab/client/tags.rb +96 -0
  41. data/lib/gitlab/client/users.rb +250 -0
  42. data/lib/gitlab/configuration.rb +55 -0
  43. data/lib/gitlab/error.rb +85 -0
  44. data/lib/gitlab/file_response.rb +46 -0
  45. data/lib/gitlab/help.rb +95 -0
  46. data/lib/gitlab/objectified_hash.rb +34 -0
  47. data/lib/gitlab/page_links.rb +33 -0
  48. data/lib/gitlab/paginated_response.rb +97 -0
  49. data/lib/gitlab/request.rb +117 -0
  50. data/lib/gitlab/shell.rb +84 -0
  51. data/lib/gitlab/shell_history.rb +59 -0
  52. data/lib/gitlab/version.rb +3 -0
  53. data/spec/fixtures/branch.json +1 -0
  54. data/spec/fixtures/branch_delete.json +3 -0
  55. data/spec/fixtures/branches.json +1 -0
  56. data/spec/fixtures/build.json +38 -0
  57. data/spec/fixtures/build_artifacts.json +0 -0
  58. data/spec/fixtures/build_cancel.json +24 -0
  59. data/spec/fixtures/build_erase.json +24 -0
  60. data/spec/fixtures/build_retry.json +24 -0
  61. data/spec/fixtures/builds.json +78 -0
  62. data/spec/fixtures/builds_commits.json +64 -0
  63. data/spec/fixtures/compare_merge_request_diff.json +31 -0
  64. data/spec/fixtures/error_already_exists.json +1 -0
  65. data/spec/fixtures/error_project_not_found.json +1 -0
  66. data/spec/fixtures/get_repository_file.json +1 -0
  67. data/spec/fixtures/git_hook.json +1 -0
  68. data/spec/fixtures/group.json +60 -0
  69. data/spec/fixtures/group_create.json +1 -0
  70. data/spec/fixtures/group_create_with_description.json +1 -0
  71. data/spec/fixtures/group_delete.json +1 -0
  72. data/spec/fixtures/group_member.json +1 -0
  73. data/spec/fixtures/group_member_delete.json +1 -0
  74. data/spec/fixtures/group_member_edit.json +1 -0
  75. data/spec/fixtures/group_members.json +1 -0
  76. data/spec/fixtures/group_projects.json +44 -0
  77. data/spec/fixtures/group_search.json +2 -0
  78. data/spec/fixtures/groups.json +2 -0
  79. data/spec/fixtures/issue.json +1 -0
  80. data/spec/fixtures/issues.json +1 -0
  81. data/spec/fixtures/key.json +1 -0
  82. data/spec/fixtures/keys.json +1 -0
  83. data/spec/fixtures/label.json +1 -0
  84. data/spec/fixtures/labels.json +1 -0
  85. data/spec/fixtures/merge_request.json +1 -0
  86. data/spec/fixtures/merge_request_changes.json +1 -0
  87. data/spec/fixtures/merge_request_comment.json +1 -0
  88. data/spec/fixtures/merge_request_comments.json +1 -0
  89. data/spec/fixtures/merge_request_commits.json +1 -0
  90. data/spec/fixtures/merge_requests.json +1 -0
  91. data/spec/fixtures/milestone.json +1 -0
  92. data/spec/fixtures/milestone_issues.json +1 -0
  93. data/spec/fixtures/milestones.json +1 -0
  94. data/spec/fixtures/namespaces.json +1 -0
  95. data/spec/fixtures/note.json +1 -0
  96. data/spec/fixtures/notes.json +1 -0
  97. data/spec/fixtures/pipeline.json +23 -0
  98. data/spec/fixtures/pipeline_cancel.json +23 -0
  99. data/spec/fixtures/pipeline_create.json +23 -0
  100. data/spec/fixtures/pipeline_retry.json +23 -0
  101. data/spec/fixtures/pipelines.json +48 -0
  102. data/spec/fixtures/project.json +1 -0
  103. data/spec/fixtures/project_commit.json +13 -0
  104. data/spec/fixtures/project_commit_comment.json +1 -0
  105. data/spec/fixtures/project_commit_comments.json +1 -0
  106. data/spec/fixtures/project_commit_diff.json +10 -0
  107. data/spec/fixtures/project_commit_status.json +42 -0
  108. data/spec/fixtures/project_commits.json +1 -0
  109. data/spec/fixtures/project_edit.json +21 -0
  110. data/spec/fixtures/project_events.json +1 -0
  111. data/spec/fixtures/project_for_user.json +1 -0
  112. data/spec/fixtures/project_fork.json +50 -0
  113. data/spec/fixtures/project_fork_link.json +1 -0
  114. data/spec/fixtures/project_forked_for_user.json +50 -0
  115. data/spec/fixtures/project_hook.json +1 -0
  116. data/spec/fixtures/project_hooks.json +1 -0
  117. data/spec/fixtures/project_issues.json +1 -0
  118. data/spec/fixtures/project_key.json +6 -0
  119. data/spec/fixtures/project_keys.json +6 -0
  120. data/spec/fixtures/project_runner_enable.json +7 -0
  121. data/spec/fixtures/project_runners.json +16 -0
  122. data/spec/fixtures/project_search.json +1 -0
  123. data/spec/fixtures/project_star.json +44 -0
  124. data/spec/fixtures/project_tag_annotated.json +1 -0
  125. data/spec/fixtures/project_tag_lightweight.json +1 -0
  126. data/spec/fixtures/project_tags.json +1 -0
  127. data/spec/fixtures/project_unstar.json +44 -0
  128. data/spec/fixtures/project_update_commit_status.json +20 -0
  129. data/spec/fixtures/projects.json +1 -0
  130. data/spec/fixtures/raw_file.json +2 -0
  131. data/spec/fixtures/release_create.json +1 -0
  132. data/spec/fixtures/release_update.json +1 -0
  133. data/spec/fixtures/repository_file.json +1 -0
  134. data/spec/fixtures/runner.json +26 -0
  135. data/spec/fixtures/runner_delete.json +7 -0
  136. data/spec/fixtures/runner_edit.json +26 -0
  137. data/spec/fixtures/runners.json +16 -0
  138. data/spec/fixtures/runners_all.json +30 -0
  139. data/spec/fixtures/service.json +1 -0
  140. data/spec/fixtures/session.json +1 -0
  141. data/spec/fixtures/shell_history.json +2 -0
  142. data/spec/fixtures/snippet.json +1 -0
  143. data/spec/fixtures/snippet_content.json +3 -0
  144. data/spec/fixtures/snippets.json +1 -0
  145. data/spec/fixtures/system_hook.json +1 -0
  146. data/spec/fixtures/system_hooks.json +1 -0
  147. data/spec/fixtures/tag.json +1 -0
  148. data/spec/fixtures/tag_create.json +1 -0
  149. data/spec/fixtures/tag_create_with_description.json +1 -0
  150. data/spec/fixtures/tag_delete.json +1 -0
  151. data/spec/fixtures/tags.json +1 -0
  152. data/spec/fixtures/team_member.json +1 -0
  153. data/spec/fixtures/team_members.json +1 -0
  154. data/spec/fixtures/tree.json +1 -0
  155. data/spec/fixtures/trigger.json +7 -0
  156. data/spec/fixtures/triggers.json +16 -0
  157. data/spec/fixtures/user.json +1 -0
  158. data/spec/fixtures/user_block_unblock.json +1 -0
  159. data/spec/fixtures/user_email.json +1 -0
  160. data/spec/fixtures/user_emails.json +1 -0
  161. data/spec/fixtures/user_search.json +1 -0
  162. data/spec/fixtures/users.json +1 -0
  163. data/spec/fixtures/variable.json +4 -0
  164. data/spec/fixtures/variables.json +10 -0
  165. data/spec/gitlab/cli_helpers_spec.rb +57 -0
  166. data/spec/gitlab/cli_spec.rb +110 -0
  167. data/spec/gitlab/client/branches_spec.rb +99 -0
  168. data/spec/gitlab/client/build_triggers_spec.rb +67 -0
  169. data/spec/gitlab/client/build_variables_spec.rb +86 -0
  170. data/spec/gitlab/client/builds_spec.rb +148 -0
  171. data/spec/gitlab/client/client_spec.rb +11 -0
  172. data/spec/gitlab/client/commits_spec.rb +137 -0
  173. data/spec/gitlab/client/groups_spec.rb +197 -0
  174. data/spec/gitlab/client/issues_spec.rb +138 -0
  175. data/spec/gitlab/client/labels_spec.rb +68 -0
  176. data/spec/gitlab/client/merge_requests_spec.rb +177 -0
  177. data/spec/gitlab/client/milestones_spec.rb +82 -0
  178. data/spec/gitlab/client/namespaces_spec.rb +22 -0
  179. data/spec/gitlab/client/notes_spec.rb +205 -0
  180. data/spec/gitlab/client/pipelines_spec.rb +95 -0
  181. data/spec/gitlab/client/projects_spec.rb +603 -0
  182. data/spec/gitlab/client/repositories_spec.rb +109 -0
  183. data/spec/gitlab/client/repository_files_spec.rb +62 -0
  184. data/spec/gitlab/client/runners_spec.rb +185 -0
  185. data/spec/gitlab/client/services_spec.rb +55 -0
  186. data/spec/gitlab/client/snippets_spec.rb +100 -0
  187. data/spec/gitlab/client/system_hooks_spec.rb +69 -0
  188. data/spec/gitlab/client/tags_spec.rb +109 -0
  189. data/spec/gitlab/client/users_spec.rb +418 -0
  190. data/spec/gitlab/error_spec.rb +45 -0
  191. data/spec/gitlab/file_response_spec.rb +33 -0
  192. data/spec/gitlab/help_spec.rb +46 -0
  193. data/spec/gitlab/objectified_hash_spec.rb +48 -0
  194. data/spec/gitlab/page_links_spec.rb +16 -0
  195. data/spec/gitlab/paginated_response_spec.rb +60 -0
  196. data/spec/gitlab/request_spec.rb +73 -0
  197. data/spec/gitlab/shell_history_spec.rb +53 -0
  198. data/spec/gitlab/shell_spec.rb +80 -0
  199. data/spec/gitlab_spec.rb +97 -0
  200. data/spec/spec_helper.rb +74 -0
  201. metadata +476 -0
@@ -0,0 +1,68 @@
1
+ require 'spec_helper'
2
+
3
+ describe Gitlab::Client do
4
+ describe ".labels" do
5
+ before do
6
+ stub_get("/projects/3/labels", "labels")
7
+ @labels = Gitlab.labels(3)
8
+ end
9
+
10
+ it "should get the correct resource" do
11
+ expect(a_get("/projects/3/labels")).to have_been_made
12
+ end
13
+
14
+ it "should return a paginated response of project's labels" do
15
+ expect(@labels).to be_a Gitlab::PaginatedResponse
16
+ expect(@labels.first.name).to eq("Backlog")
17
+ end
18
+ end
19
+
20
+ describe ".delete" do
21
+ before do
22
+ stub_delete("/projects/3/labels", "label")
23
+ @label = Gitlab.delete_label(3, "Backlog")
24
+ end
25
+
26
+ it "should get the correct resource" do
27
+ expect(a_delete("/projects/3/labels").
28
+ with(body: { name: 'Backlog' })).to have_been_made
29
+ end
30
+
31
+ it "should return information about a deleted snippet" do
32
+ expect(@label.name).to eq("Backlog")
33
+ end
34
+ end
35
+
36
+ describe ".edit_label" do
37
+ before do
38
+ stub_put("/projects/3/labels", "label")
39
+ @label = Gitlab.edit_label(3, "TODO", new_name: 'Backlog')
40
+ end
41
+
42
+ it "should get the correct resource" do
43
+ expect(a_put("/projects/3/labels").
44
+ with(body: { name: 'TODO', new_name: "Backlog" })).to have_been_made
45
+ end
46
+
47
+ it "should return information about an edited label" do
48
+ expect(@label.name).to eq("Backlog")
49
+ end
50
+ end
51
+
52
+ describe ".create_label" do
53
+ before do
54
+ stub_post("/projects/3/labels", "label")
55
+ @label = Gitlab.create_label(3, 'Backlog', '#DD10AA')
56
+ end
57
+
58
+ it "should get the correct resource" do
59
+ expect(a_post("/projects/3/labels").
60
+ with(body: { name: 'Backlog', color: '#DD10AA' })).to have_been_made
61
+ end
62
+
63
+ it "should return information about a created label" do
64
+ expect(@label.name).to eq('Backlog')
65
+ expect(@label.color).to eq('#DD10AA')
66
+ end
67
+ end
68
+ end
@@ -0,0 +1,177 @@
1
+ require 'spec_helper'
2
+
3
+ describe Gitlab::Client do
4
+ describe ".merge_requests" do
5
+ before do
6
+ stub_get("/projects/3/merge_requests", "merge_requests")
7
+ @merge_requests = Gitlab.merge_requests(3)
8
+ end
9
+
10
+ it "should get the correct resource" do
11
+ expect(a_get("/projects/3/merge_requests")).to have_been_made
12
+ end
13
+
14
+ it "should return a paginated response of project's merge requests" do
15
+ expect(@merge_requests).to be_a Gitlab::PaginatedResponse
16
+ expect(@merge_requests.first.project_id).to eq(3)
17
+ end
18
+ end
19
+
20
+ describe ".merge_request" do
21
+ before do
22
+ stub_get("/projects/3/merge_request/1", "merge_request")
23
+ @merge_request = Gitlab.merge_request(3, 1)
24
+ end
25
+
26
+ it "should get the correct resource" do
27
+ expect(a_get("/projects/3/merge_request/1")).to have_been_made
28
+ end
29
+
30
+ it "should return information about a merge request" do
31
+ expect(@merge_request.project_id).to eq(3)
32
+ expect(@merge_request.assignee.name).to eq("Jack Smith")
33
+ end
34
+ end
35
+
36
+ describe ".create_merge_request" do
37
+ before do
38
+ stub_post("/projects/3/merge_requests", "merge_request")
39
+ end
40
+
41
+ it "should return information about a merge request" do
42
+ @merge_request = Gitlab.create_merge_request(3, 'New feature',
43
+ source_branch: 'api',
44
+ target_branch: 'master'
45
+ )
46
+ expect(@merge_request.project_id).to eq(3)
47
+ expect(@merge_request.assignee.name).to eq("Jack Smith")
48
+ end
49
+ end
50
+
51
+ describe ".update_merge_request" do
52
+ before do
53
+ stub_put("/projects/3/merge_request/2", "merge_request").
54
+ with(body: {
55
+ assignee_id: '1',
56
+ target_branch: 'master',
57
+ title: 'A different new feature'
58
+ })
59
+ @merge_request = Gitlab.update_merge_request(3, 2,
60
+ assignee_id: '1',
61
+ target_branch: 'master',
62
+ title: 'A different new feature'
63
+ )
64
+ end
65
+
66
+ it "should get the correct resource" do
67
+ expect(a_put("/projects/3/merge_request/2").
68
+ with(body: {
69
+ assignee_id: '1',
70
+ target_branch: 'master',
71
+ title: 'A different new feature'
72
+ })).to have_been_made
73
+ end
74
+
75
+ it "should return information about a merge request" do
76
+ expect(@merge_request.project_id).to eq(3)
77
+ expect(@merge_request.assignee.name).to eq("Jack Smith")
78
+ end
79
+ end
80
+
81
+ describe ".accept_merge_request" do
82
+ before do
83
+ stub_put("/projects/5/merge_request/42/merge", "merge_request").
84
+ with(body: { merge_commit_message: 'Nice!' })
85
+ @merge_request = Gitlab.accept_merge_request(5, 42, merge_commit_message: 'Nice!')
86
+ end
87
+
88
+ it "should get the correct resource" do
89
+ expect(a_put("/projects/5/merge_request/42/merge").
90
+ with(body: { merge_commit_message: 'Nice!' })).to have_been_made
91
+ end
92
+
93
+ it "should return information about merged merge request" do
94
+ expect(@merge_request.project_id).to eq(3)
95
+ expect(@merge_request.assignee.name).to eq("Jack Smith")
96
+ end
97
+ end
98
+
99
+ describe ".merge_request_comments" do
100
+ before do
101
+ stub_get("/projects/3/merge_requests/2/notes", "merge_request_comments")
102
+ @merge_request = Gitlab.merge_request_comments(3, 2)
103
+ end
104
+
105
+ it "should get the correct resource" do
106
+ expect(a_get("/projects/3/merge_requests/2/notes")).to have_been_made
107
+ end
108
+
109
+ it "should return merge request's comments" do
110
+ expect(@merge_request).to be_an Gitlab::PaginatedResponse
111
+ expect(@merge_request.length).to eq(2)
112
+ expect(@merge_request[0].note).to eq("this is the 1st comment on the 2merge merge request")
113
+ expect(@merge_request[0].author.id).to eq(11)
114
+ expect(@merge_request[1].note).to eq("another discussion point on the 2merge request")
115
+ expect(@merge_request[1].author.id).to eq(12)
116
+ end
117
+ end
118
+
119
+ describe ".create_merge_request_comment" do
120
+ before do
121
+ stub_post("/projects/3/merge_requests/2/notes", "merge_request_comment")
122
+ @merge_request = Gitlab.create_merge_request_comment(3, 2, 'Cool Merge Request!')
123
+ end
124
+
125
+ it "should get the correct resource" do
126
+ expect(a_post("/projects/3/merge_requests/2/notes")).to have_been_made
127
+ end
128
+
129
+ it "should return information about a merge request" do
130
+ expect(@merge_request.note).to eq('Cool Merge Request!')
131
+ expect(@merge_request.author.id).to eq(1)
132
+ end
133
+ end
134
+
135
+ describe ".merge_request_changes" do
136
+ before do
137
+ stub_get("/projects/3/merge_request/2/changes", "merge_request_changes")
138
+ @mr_changes = Gitlab.merge_request_changes(3, 2)
139
+ end
140
+
141
+ it "should get the correct resource" do
142
+ expect(a_get("/projects/3/merge_request/2/changes")).to have_been_made
143
+ end
144
+
145
+ it "should return the merge request changes" do
146
+ expect(@mr_changes.changes).to be_a Array
147
+ expect(@mr_changes.changes.first['old_path']).to eq('lib/omniauth/builder.rb')
148
+ expect(@mr_changes.id).to eq(2)
149
+ expect(@mr_changes.project_id).to eq(3)
150
+ expect(@mr_changes.source_branch).to eq('uncovered')
151
+ expect(@mr_changes.target_branch).to eq('master')
152
+ end
153
+ end
154
+
155
+ describe ".merge_request_commits" do
156
+ before do
157
+ stub_get("/projects/3/merge_request/2/commits", "merge_request_commits")
158
+ @mr_commits = Gitlab.merge_request_commits(3, 2)
159
+ end
160
+
161
+ it "should get the correct resource" do
162
+ expect(a_get("/projects/3/merge_request/2/commits")).to have_been_made
163
+ end
164
+
165
+ it "should return the merge request commits" do
166
+ expect(@mr_commits).to be_a Gitlab::PaginatedResponse
167
+ expect(@mr_commits.size).to eq 2
168
+ expect(@mr_commits.first.id).to eq "a2da7552f26d5b46a6a09bb8b7b066e3a102be7d"
169
+ expect(@mr_commits.first.short_id).to eq "a2da7552"
170
+ expect(@mr_commits.first.title).to eq "piyo"
171
+ expect(@mr_commits.first.author_name).to eq "example"
172
+ expect(@mr_commits.first.author_email).to eq "example@example.com"
173
+ expect(@mr_commits[1].short_id).to eq "3ce50959"
174
+ expect(@mr_commits[1].title).to eq "hoge"
175
+ end
176
+ end
177
+ end
@@ -0,0 +1,82 @@
1
+ require 'spec_helper'
2
+
3
+ describe Gitlab::Client do
4
+ describe ".milestones" do
5
+ before do
6
+ stub_get("/projects/3/milestones", "milestones")
7
+ @milestones = Gitlab.milestones(3)
8
+ end
9
+
10
+ it "should get the correct resource" do
11
+ expect(a_get("/projects/3/milestones")).to have_been_made
12
+ end
13
+
14
+ it "should return a paginated response of project's milestones" do
15
+ expect(@milestones).to be_a Gitlab::PaginatedResponse
16
+ expect(@milestones.first.project_id).to eq(3)
17
+ end
18
+ end
19
+
20
+ describe ".milestone" do
21
+ before do
22
+ stub_get("/projects/3/milestones/1", "milestone")
23
+ @milestone = Gitlab.milestone(3, 1)
24
+ end
25
+
26
+ it "should get the correct resource" do
27
+ expect(a_get("/projects/3/milestones/1")).to have_been_made
28
+ end
29
+
30
+ it "should return information about a milestone" do
31
+ expect(@milestone.project_id).to eq(3)
32
+ end
33
+ end
34
+
35
+ describe ".milestone_issues" do
36
+ before do
37
+ stub_get("/projects/3/milestones/1/issues", "milestone_issues")
38
+ @milestone_issues = Gitlab.milestone_issues(3, 1)
39
+ end
40
+
41
+ it "should get the correct resource" do
42
+ expect(a_get("/projects/3/milestones/1/issues")).to have_been_made
43
+ end
44
+
45
+ it "should return a paginated response of milestone's issues" do
46
+ expect(@milestone_issues).to be_a Gitlab::PaginatedResponse
47
+ expect(@milestone_issues.first.milestone.id).to eq(1)
48
+ end
49
+ end
50
+
51
+ describe ".create_milestone" do
52
+ before do
53
+ stub_post("/projects/3/milestones", "milestone")
54
+ @milestone = Gitlab.create_milestone(3, 'title')
55
+ end
56
+
57
+ it "should get the correct resource" do
58
+ expect(a_post("/projects/3/milestones").
59
+ with(body: { title: 'title' })).to have_been_made
60
+ end
61
+
62
+ it "should return information about a created milestone" do
63
+ expect(@milestone.project_id).to eq(3)
64
+ end
65
+ end
66
+
67
+ describe ".edit_milestone" do
68
+ before do
69
+ stub_put("/projects/3/milestones/33", "milestone")
70
+ @milestone = Gitlab.edit_milestone(3, 33, title: 'title')
71
+ end
72
+
73
+ it "should get the correct resource" do
74
+ expect(a_put("/projects/3/milestones/33").
75
+ with(body: { title: 'title' })).to have_been_made
76
+ end
77
+
78
+ it "should return information about an edited milestone" do
79
+ expect(@milestone.project_id).to eq(3)
80
+ end
81
+ end
82
+ end
@@ -0,0 +1,22 @@
1
+ require 'spec_helper'
2
+
3
+ describe Gitlab::Client do
4
+ it { should respond_to :namespaces }
5
+
6
+ describe ".namespaces" do
7
+ before do
8
+ stub_get("/namespaces", "namespaces")
9
+ @namespaces = Gitlab.namespaces
10
+ end
11
+
12
+ it "should get the correct resource" do
13
+ expect(a_get("/namespaces")).to have_been_made
14
+ end
15
+
16
+ it "should return a paginated response of namespaces" do
17
+ expect(@namespaces).to be_a Gitlab::PaginatedResponse
18
+ expect(@namespaces.first.path).to eq("john")
19
+ expect(@namespaces.first.kind).to eq("user")
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,205 @@
1
+ require 'spec_helper'
2
+
3
+ describe Gitlab::Client do
4
+ describe "notes" do
5
+ context "when wall notes" do
6
+ before do
7
+ stub_get("/projects/3/notes", "notes")
8
+ @notes = Gitlab.notes(3)
9
+ end
10
+
11
+ it "should get the correct resource" do
12
+ expect(a_get("/projects/3/notes")).to have_been_made
13
+ end
14
+
15
+ it "should return a paginated response of notes" do
16
+ expect(@notes).to be_a Gitlab::PaginatedResponse
17
+ expect(@notes.first.author.name).to eq("John Smith")
18
+ end
19
+ end
20
+
21
+ context "when issue notes" do
22
+ before do
23
+ stub_get("/projects/3/issues/7/notes", "notes")
24
+ @notes = Gitlab.issue_notes(3, 7)
25
+ end
26
+
27
+ it "should get the correct resource" do
28
+ expect(a_get("/projects/3/issues/7/notes")).to have_been_made
29
+ end
30
+
31
+ it "should return a paginated response of notes" do
32
+ expect(@notes).to be_a Gitlab::PaginatedResponse
33
+ expect(@notes.first.author.name).to eq("John Smith")
34
+ end
35
+ end
36
+
37
+ context "when snippet notes" do
38
+ before do
39
+ stub_get("/projects/3/snippets/7/notes", "notes")
40
+ @notes = Gitlab.snippet_notes(3, 7)
41
+ end
42
+
43
+ it "should get the correct resource" do
44
+ expect(a_get("/projects/3/snippets/7/notes")).to have_been_made
45
+ end
46
+
47
+ it "should return a paginated response of notes" do
48
+ expect(@notes).to be_a Gitlab::PaginatedResponse
49
+ expect(@notes.first.author.name).to eq("John Smith")
50
+ end
51
+ end
52
+
53
+ context "when merge_request notes" do
54
+ before do
55
+ stub_get("/projects/3/merge_requests/7/notes", "notes")
56
+ @notes = Gitlab.merge_request_notes(3, 7)
57
+ end
58
+
59
+ it "should get the correct resource" do
60
+ expect(a_get("/projects/3/merge_requests/7/notes")).to have_been_made
61
+ end
62
+
63
+ it "should return a paginated response of notes" do
64
+ expect(@notes).to be_a Gitlab::PaginatedResponse
65
+ expect(@notes.first.author.name).to eq("John Smith")
66
+ end
67
+ end
68
+ end
69
+
70
+ describe "note" do
71
+ context "when wall note" do
72
+ before do
73
+ stub_get("/projects/3/notes/1201", "note")
74
+ @note = Gitlab.note(3, 1201)
75
+ end
76
+
77
+ it "should get the correct resource" do
78
+ expect(a_get("/projects/3/notes/1201")).to have_been_made
79
+ end
80
+
81
+ it "should return information about a note" do
82
+ expect(@note.body).to eq("The solution is rather tricky")
83
+ expect(@note.author.name).to eq("John Smith")
84
+ end
85
+ end
86
+
87
+ context "when issue note" do
88
+ before do
89
+ stub_get("/projects/3/issues/7/notes/1201", "note")
90
+ @note = Gitlab.issue_note(3, 7, 1201)
91
+ end
92
+
93
+ it "should get the correct resource" do
94
+ expect(a_get("/projects/3/issues/7/notes/1201")).to have_been_made
95
+ end
96
+
97
+ it "should return information about a note" do
98
+ expect(@note.body).to eq("The solution is rather tricky")
99
+ expect(@note.author.name).to eq("John Smith")
100
+ end
101
+ end
102
+
103
+ context "when snippet note" do
104
+ before do
105
+ stub_get("/projects/3/snippets/7/notes/1201", "note")
106
+ @note = Gitlab.snippet_note(3, 7, 1201)
107
+ end
108
+
109
+ it "should get the correct resource" do
110
+ expect(a_get("/projects/3/snippets/7/notes/1201")).to have_been_made
111
+ end
112
+
113
+ it "should return information about a note" do
114
+ expect(@note.body).to eq("The solution is rather tricky")
115
+ expect(@note.author.name).to eq("John Smith")
116
+ end
117
+ end
118
+
119
+ context "when merge request note" do
120
+ before do
121
+ stub_get("/projects/3/merge_requests/7/notes/1201", "note")
122
+ @note = Gitlab.merge_request_note(3, 7, 1201)
123
+ end
124
+
125
+ it "should get the correct resource" do
126
+ expect(a_get("/projects/3/merge_requests/7/notes/1201")).to have_been_made
127
+ end
128
+
129
+ it "should return information about a note" do
130
+ expect(@note.body).to eq("The solution is rather tricky")
131
+ expect(@note.author.name).to eq("John Smith")
132
+ end
133
+ end
134
+ end
135
+
136
+ describe "create note" do
137
+ context "when wall note" do
138
+ before do
139
+ stub_post("/projects/3/notes", "note")
140
+ @note = Gitlab.create_note(3, "The solution is rather tricky")
141
+ end
142
+
143
+ it "should get the correct resource" do
144
+ expect(a_post("/projects/3/notes").
145
+ with(body: { body: 'The solution is rather tricky' })).to have_been_made
146
+ end
147
+
148
+ it "should return information about a created note" do
149
+ expect(@note.body).to eq("The solution is rather tricky")
150
+ expect(@note.author.name).to eq("John Smith")
151
+ end
152
+ end
153
+
154
+ context "when issue note" do
155
+ before do
156
+ stub_post("/projects/3/issues/7/notes", "note")
157
+ @note = Gitlab.create_issue_note(3, 7, "The solution is rather tricky")
158
+ end
159
+
160
+ it "should get the correct resource" do
161
+ expect(a_post("/projects/3/issues/7/notes").
162
+ with(body: { body: 'The solution is rather tricky' })).to have_been_made
163
+ end
164
+
165
+ it "should return information about a created note" do
166
+ expect(@note.body).to eq("The solution is rather tricky")
167
+ expect(@note.author.name).to eq("John Smith")
168
+ end
169
+ end
170
+
171
+ context "when snippet note" do
172
+ before do
173
+ stub_post("/projects/3/snippets/7/notes", "note")
174
+ @note = Gitlab.create_snippet_note(3, 7, "The solution is rather tricky")
175
+ end
176
+
177
+ it "should get the correct resource" do
178
+ expect(a_post("/projects/3/snippets/7/notes").
179
+ with(body: { body: 'The solution is rather tricky' })).to have_been_made
180
+ end
181
+
182
+ it "should return information about a created note" do
183
+ expect(@note.body).to eq("The solution is rather tricky")
184
+ expect(@note.author.name).to eq("John Smith")
185
+ end
186
+ end
187
+
188
+ context "when merge_request note" do
189
+ before do
190
+ stub_post("/projects/3/merge_requests/7/notes", "note")
191
+ @note = Gitlab.create_merge_request_note(3, 7, "The solution is rather tricky")
192
+ end
193
+
194
+ it "should get the correct resource" do
195
+ expect(a_post("/projects/3/merge_requests/7/notes").
196
+ with(body: { body: 'The solution is rather tricky' })).to have_been_made
197
+ end
198
+
199
+ it "should return information about a created note" do
200
+ expect(@note.body).to eq("The solution is rather tricky")
201
+ expect(@note.author.name).to eq("John Smith")
202
+ end
203
+ end
204
+ end
205
+ end