gitlab 3.0.0 → 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 (172) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +4 -0
  3. data/.travis.yml +6 -2
  4. data/CHANGELOG.md +244 -0
  5. data/CONTRIBUTING.md +195 -0
  6. data/LICENSE.txt +1 -1
  7. data/README.md +122 -10
  8. data/Rakefile +1 -1
  9. data/bin/console +10 -0
  10. data/bin/setup +6 -0
  11. data/exe/gitlab +7 -0
  12. data/gitlab.gemspec +9 -3
  13. data/lib/gitlab.rb +18 -2
  14. data/lib/gitlab/api.rb +6 -4
  15. data/lib/gitlab/cli.rb +89 -0
  16. data/lib/gitlab/cli_helpers.rb +241 -0
  17. data/lib/gitlab/client.rb +42 -6
  18. data/lib/gitlab/client/branches.rb +91 -0
  19. data/lib/gitlab/client/build_triggers.rb +51 -0
  20. data/lib/gitlab/client/build_variables.rb +66 -0
  21. data/lib/gitlab/client/builds.rb +106 -0
  22. data/lib/gitlab/client/commits.rb +146 -0
  23. data/lib/gitlab/client/groups.rb +66 -10
  24. data/lib/gitlab/client/issues.rb +61 -16
  25. data/lib/gitlab/client/labels.rb +57 -0
  26. data/lib/gitlab/client/merge_requests.rb +137 -26
  27. data/lib/gitlab/client/milestones.rb +44 -9
  28. data/lib/gitlab/client/namespaces.rb +20 -0
  29. data/lib/gitlab/client/notes.rb +71 -16
  30. data/lib/gitlab/client/pipelines.rb +68 -0
  31. data/lib/gitlab/client/projects.rb +236 -27
  32. data/lib/gitlab/client/repositories.rb +39 -45
  33. data/lib/gitlab/client/repository_files.rb +107 -0
  34. data/lib/gitlab/client/runners.rb +115 -0
  35. data/lib/gitlab/client/services.rb +50 -0
  36. data/lib/gitlab/client/snippets.rb +26 -21
  37. data/lib/gitlab/client/system_hooks.rb +59 -0
  38. data/lib/gitlab/client/tags.rb +96 -0
  39. data/lib/gitlab/client/users.rb +151 -7
  40. data/lib/gitlab/configuration.rb +20 -4
  41. data/lib/gitlab/error.rb +55 -12
  42. data/lib/gitlab/file_response.rb +46 -0
  43. data/lib/gitlab/help.rb +95 -0
  44. data/lib/gitlab/objectified_hash.rb +19 -3
  45. data/lib/gitlab/page_links.rb +33 -0
  46. data/lib/gitlab/paginated_response.rb +97 -0
  47. data/lib/gitlab/request.rb +65 -33
  48. data/lib/gitlab/shell.rb +84 -0
  49. data/lib/gitlab/shell_history.rb +59 -0
  50. data/lib/gitlab/version.rb +1 -1
  51. data/spec/fixtures/{project_branch.json → branch.json} +1 -1
  52. data/spec/fixtures/branch_delete.json +3 -0
  53. data/spec/fixtures/{project_branches.json → branches.json} +0 -0
  54. data/spec/fixtures/build.json +38 -0
  55. data/spec/fixtures/build_artifacts.json +0 -0
  56. data/spec/fixtures/build_cancel.json +24 -0
  57. data/spec/fixtures/build_erase.json +24 -0
  58. data/spec/fixtures/build_retry.json +24 -0
  59. data/spec/fixtures/builds.json +78 -0
  60. data/spec/fixtures/builds_commits.json +64 -0
  61. data/spec/fixtures/compare_merge_request_diff.json +31 -0
  62. data/spec/fixtures/error_project_not_found.json +1 -0
  63. data/spec/fixtures/get_repository_file.json +1 -0
  64. data/spec/fixtures/group_create_with_description.json +1 -0
  65. data/spec/fixtures/group_delete.json +1 -0
  66. data/spec/fixtures/group_member_edit.json +1 -0
  67. data/spec/fixtures/group_projects.json +44 -0
  68. data/spec/fixtures/group_search.json +2 -0
  69. data/spec/fixtures/label.json +1 -0
  70. data/spec/fixtures/labels.json +1 -0
  71. data/spec/fixtures/merge_request_changes.json +1 -0
  72. data/spec/fixtures/merge_request_closes_issues.json +1 -0
  73. data/spec/fixtures/{comment_merge_request.json → merge_request_comment.json} +0 -0
  74. data/spec/fixtures/merge_request_comments.json +1 -0
  75. data/spec/fixtures/merge_request_commits.json +1 -0
  76. data/spec/fixtures/milestone_issues.json +1 -0
  77. data/spec/fixtures/milestone_merge_requests.json +1 -0
  78. data/spec/fixtures/namespaces.json +1 -0
  79. data/spec/fixtures/pipeline.json +23 -0
  80. data/spec/fixtures/pipeline_cancel.json +23 -0
  81. data/spec/fixtures/pipeline_create.json +23 -0
  82. data/spec/fixtures/pipeline_retry.json +23 -0
  83. data/spec/fixtures/pipelines.json +48 -0
  84. data/spec/fixtures/project_commit.json +13 -0
  85. data/spec/fixtures/project_commit_comment.json +1 -0
  86. data/spec/fixtures/project_commit_comments.json +1 -0
  87. data/spec/fixtures/project_commit_create.json +22 -0
  88. data/spec/fixtures/project_commit_diff.json +10 -0
  89. data/spec/fixtures/project_commit_status.json +42 -0
  90. data/spec/fixtures/project_edit.json +21 -0
  91. data/spec/fixtures/project_events.json +1 -0
  92. data/spec/fixtures/project_fork.json +50 -0
  93. data/spec/fixtures/project_forked_for_user.json +50 -0
  94. data/spec/fixtures/project_runner_enable.json +7 -0
  95. data/spec/fixtures/project_runners.json +16 -0
  96. data/spec/fixtures/project_search.json +1 -0
  97. data/spec/fixtures/project_star.json +44 -0
  98. data/spec/fixtures/project_tag_annotated.json +1 -0
  99. data/spec/fixtures/project_tag_lightweight.json +1 -0
  100. data/spec/fixtures/project_unstar.json +44 -0
  101. data/spec/fixtures/project_update_commit_status.json +20 -0
  102. data/spec/fixtures/push_rule.json +1 -0
  103. data/spec/fixtures/raw_file.json +2 -0
  104. data/spec/fixtures/release_create.json +1 -0
  105. data/spec/fixtures/release_update.json +1 -0
  106. data/spec/fixtures/repository_file.json +1 -0
  107. data/spec/fixtures/runner.json +26 -0
  108. data/spec/fixtures/runner_delete.json +7 -0
  109. data/spec/fixtures/runner_edit.json +26 -0
  110. data/spec/fixtures/runners.json +16 -0
  111. data/spec/fixtures/runners_all.json +30 -0
  112. data/spec/fixtures/service.json +1 -0
  113. data/spec/fixtures/shell_history.json +2 -0
  114. data/spec/fixtures/snippet_content.json +3 -0
  115. data/spec/fixtures/system_hook.json +1 -0
  116. data/spec/fixtures/system_hooks.json +1 -0
  117. data/spec/fixtures/tag.json +1 -0
  118. data/spec/fixtures/tag_create.json +1 -0
  119. data/spec/fixtures/tag_create_with_description.json +1 -0
  120. data/spec/fixtures/tag_delete.json +1 -0
  121. data/spec/fixtures/tags.json +1 -0
  122. data/spec/fixtures/tree.json +1 -0
  123. data/spec/fixtures/trigger.json +7 -0
  124. data/spec/fixtures/triggers.json +16 -0
  125. data/spec/fixtures/user.json +1 -1
  126. data/spec/fixtures/user_block_unblock.json +1 -0
  127. data/spec/fixtures/user_email.json +1 -0
  128. data/spec/fixtures/user_emails.json +1 -0
  129. data/spec/fixtures/user_search.json +1 -0
  130. data/spec/fixtures/users.json +1 -1
  131. data/spec/fixtures/variable.json +4 -0
  132. data/spec/fixtures/variables.json +10 -0
  133. data/spec/gitlab/cli_helpers_spec.rb +57 -0
  134. data/spec/gitlab/cli_spec.rb +119 -0
  135. data/spec/gitlab/client/branches_spec.rb +99 -0
  136. data/spec/gitlab/client/build_triggers_spec.rb +67 -0
  137. data/spec/gitlab/client/build_variables_spec.rb +86 -0
  138. data/spec/gitlab/client/builds_spec.rb +148 -0
  139. data/spec/gitlab/client/client_spec.rb +11 -0
  140. data/spec/gitlab/client/commits_spec.rb +168 -0
  141. data/spec/gitlab/client/groups_spec.rb +116 -30
  142. data/spec/gitlab/client/issues_spec.rb +93 -29
  143. data/spec/gitlab/client/labels_spec.rb +68 -0
  144. data/spec/gitlab/client/merge_requests_spec.rb +171 -39
  145. data/spec/gitlab/client/milestones_spec.rb +45 -13
  146. data/spec/gitlab/client/namespaces_spec.rb +22 -0
  147. data/spec/gitlab/client/notes_spec.rb +82 -33
  148. data/spec/gitlab/client/pipelines_spec.rb +95 -0
  149. data/spec/gitlab/client/projects_spec.rb +371 -71
  150. data/spec/gitlab/client/repositories_spec.rb +51 -30
  151. data/spec/gitlab/client/repository_files_spec.rb +77 -0
  152. data/spec/gitlab/client/runners_spec.rb +185 -0
  153. data/spec/gitlab/client/services_spec.rb +55 -0
  154. data/spec/gitlab/client/snippets_spec.rb +35 -20
  155. data/spec/gitlab/client/system_hooks_spec.rb +69 -0
  156. data/spec/gitlab/client/tags_spec.rb +109 -0
  157. data/spec/gitlab/client/users_spec.rb +296 -34
  158. data/spec/gitlab/error_spec.rb +45 -0
  159. data/spec/gitlab/file_response_spec.rb +33 -0
  160. data/spec/gitlab/help_spec.rb +46 -0
  161. data/spec/gitlab/objectified_hash_spec.rb +48 -0
  162. data/spec/gitlab/page_links_spec.rb +16 -0
  163. data/spec/gitlab/paginated_response_spec.rb +60 -0
  164. data/spec/gitlab/request_spec.rb +73 -0
  165. data/spec/gitlab/shell_history_spec.rb +53 -0
  166. data/spec/gitlab/shell_spec.rb +80 -0
  167. data/spec/gitlab_spec.rb +48 -7
  168. data/spec/spec_helper.rb +24 -13
  169. metadata +287 -33
  170. data/spec/fixtures/create_merge_request.json +0 -1
  171. data/spec/fixtures/project_delete_key.json +0 -8
  172. data/spec/fixtures/update_merge_request.json +0 -1
@@ -8,85 +8,217 @@ describe Gitlab::Client do
8
8
  end
9
9
 
10
10
  it "should get the correct resource" do
11
- a_get("/projects/3/merge_requests").should have_been_made
11
+ expect(a_get("/projects/3/merge_requests")).to have_been_made
12
12
  end
13
13
 
14
- it "should return an array of project's merge requests" do
15
- @merge_requests.should be_an Array
16
- @merge_requests.first.project_id.should == 3
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
17
  end
18
18
  end
19
19
 
20
20
  describe ".merge_request" do
21
21
  before do
22
- stub_get("/projects/3/merge_request/1", "merge_request")
22
+ stub_get("/projects/3/merge_requests/1", "merge_request")
23
23
  @merge_request = Gitlab.merge_request(3, 1)
24
24
  end
25
25
 
26
26
  it "should get the correct resource" do
27
- a_get("/projects/3/merge_request/1").should have_been_made
27
+ expect(a_get("/projects/3/merge_requests/1")).to have_been_made
28
28
  end
29
29
 
30
30
  it "should return information about a merge request" do
31
- @merge_request.project_id.should == 3
32
- @merge_request.assignee.name.should == "Jack Smith"
31
+ expect(@merge_request.project_id).to eq(3)
32
+ expect(@merge_request.assignee.name).to eq("Jack Smith")
33
33
  end
34
34
  end
35
35
 
36
36
  describe ".create_merge_request" do
37
37
  before do
38
- stub_post("/projects/3/merge_requests", "create_merge_request")
39
- end
40
-
41
- it "should fail if it doesn't have a source_branch" do
42
- expect {
43
- Gitlab.create_merge_request(3, 'New merge request', :target_branch => 'master')
44
- }.to raise_error Gitlab::Error::MissingAttributes
45
- end
46
-
47
- it "should fail if it doesn't have a target_branch" do
48
- expect {
49
- Gitlab.create_merge_request(3, 'New merge request', :source_branch => 'dev')
50
- }.to raise_error Gitlab::Error::MissingAttributes
38
+ stub_post("/projects/3/merge_requests", "merge_request")
51
39
  end
52
40
 
53
41
  it "should return information about a merge request" do
54
42
  @merge_request = Gitlab.create_merge_request(3, 'New feature',
55
- :source_branch => 'api',
56
- :target_branch => 'master'
57
- )
58
- @merge_request.project_id.should == 3
59
- @merge_request.assignee.name.should == "Jack Smith"
60
- @merge_request.title.should == '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")
61
48
  end
62
49
  end
63
50
 
64
51
  describe ".update_merge_request" do
65
52
  before do
66
- stub_put("/projects/3/merge_request/2", "update_merge_request")
53
+ stub_put("/projects/3/merge_requests/2", "merge_request").
54
+ with(body: {
55
+ assignee_id: '1',
56
+ target_branch: 'master',
57
+ title: 'A different new feature'
58
+ })
67
59
  @merge_request = Gitlab.update_merge_request(3, 2,
68
- :assignee_id => '1',
69
- :target_branch => 'master',
70
- :title => 'A different new feature'
71
- )
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_requests/2").
68
+ with(body: {
69
+ assignee_id: '1',
70
+ target_branch: 'master',
71
+ title: 'A different new feature'
72
+ })).to have_been_made
72
73
  end
73
74
 
74
75
  it "should return information about a merge request" do
75
- @merge_request.project_id.should == 3
76
- @merge_request.assignee.name.should == "Jack Smith"
77
- @merge_request.title.should == 'A different new feature'
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_requests/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_requests/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)
78
116
  end
79
117
  end
80
118
 
81
119
  describe ".create_merge_request_comment" do
82
120
  before do
83
- stub_post("/projects/3/merge_request/2/comments", "comment_merge_request")
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
84
127
  end
85
128
 
86
129
  it "should return information about a merge request" do
87
- @merge_request = Gitlab.create_merge_request_comment(3, 2, 'Cool Merge Request!')
88
- @merge_request.note.should == 'Cool Merge Request!'
89
- @merge_request.author.id == 1
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_requests/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_requests/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_requests/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_requests/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
+
178
+ describe ".merge_request_closes_issues" do
179
+ before do
180
+ stub_get("/projects/5/merge_requests/1/closes_issues", "merge_request_closes_issues")
181
+ @issues = Gitlab.merge_request_closes_issues(5, 1)
182
+ end
183
+
184
+ it "should get the correct resource" do
185
+ expect(a_get("/projects/5/merge_requests/1/closes_issues")).to have_been_made
186
+ end
187
+
188
+ it "should return a paginated response of the issues the merge_request will close" do
189
+ expect(@issues).to be_a(Gitlab::PaginatedResponse)
190
+ expect(@issues.first.title).to eq("Merge request 1 issue 1")
191
+ expect(@issues.size).to eq(2)
192
+ end
193
+ end
194
+
195
+ describe ".subscribe_to_merge_request" do
196
+ before do
197
+ stub_post("/projects/3/merge_requests/2/subscribe", "merge_request")
198
+ @merge_request = Gitlab.subscribe_to_merge_request(3, 2)
199
+ end
200
+
201
+ it "should get the correct resource" do
202
+ expect(a_post("/projects/3/merge_requests/2/subscribe")).to have_been_made
203
+ end
204
+
205
+ it "should return information about a merge request" do
206
+ expect(@merge_request.project_id).to eq(3)
207
+ end
208
+ end
209
+
210
+ describe ".unsubscribe_from_merge_request" do
211
+ before do
212
+ stub_post("/projects/3/merge_requests/2/unsubscribe", "merge_request")
213
+ @merge_request = Gitlab.unsubscribe_from_merge_request(3, 2)
214
+ end
215
+
216
+ it "should get the correct resource" do
217
+ expect(a_post("/projects/3/merge_requests/2/unsubscribe")).to have_been_made
218
+ end
219
+
220
+ it "should return information about a merge request" do
221
+ expect(@merge_request.project_id).to eq(3)
90
222
  end
91
223
  end
92
224
  end
@@ -8,12 +8,12 @@ describe Gitlab::Client do
8
8
  end
9
9
 
10
10
  it "should get the correct resource" do
11
- a_get("/projects/3/milestones").should have_been_made
11
+ expect(a_get("/projects/3/milestones")).to have_been_made
12
12
  end
13
13
 
14
- it "should return an array of project's milestones" do
15
- @milestones.should be_an Array
16
- @milestones.first.project_id.should == 3
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
17
  end
18
18
  end
19
19
 
@@ -24,11 +24,43 @@ describe Gitlab::Client do
24
24
  end
25
25
 
26
26
  it "should get the correct resource" do
27
- a_get("/projects/3/milestones/1").should have_been_made
27
+ expect(a_get("/projects/3/milestones/1")).to have_been_made
28
28
  end
29
29
 
30
30
  it "should return information about a milestone" do
31
- @milestone.project_id.should == 3
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 ".milestone_merge_requests" do
52
+ before do
53
+ stub_get("/projects/3/milestones/1/merge_requests", "milestone_merge_requests")
54
+ @milestone_merge_requests = Gitlab.milestone_merge_requests(3, 1)
55
+ end
56
+
57
+ it "should get the correct resource" do
58
+ expect(a_get("/projects/3/milestones/1/merge_requests")).to have_been_made
59
+ end
60
+
61
+ it "should return a paginated response of milestone's merge_requests" do
62
+ expect(@milestone_merge_requests).to be_a Gitlab::PaginatedResponse
63
+ expect(@milestone_merge_requests.first.milestone.id).to eq(1)
32
64
  end
33
65
  end
34
66
 
@@ -39,28 +71,28 @@ describe Gitlab::Client do
39
71
  end
40
72
 
41
73
  it "should get the correct resource" do
42
- a_post("/projects/3/milestones").
43
- with(:body => {:title => 'title'}).should have_been_made
74
+ expect(a_post("/projects/3/milestones").
75
+ with(body: { title: 'title' })).to have_been_made
44
76
  end
45
77
 
46
78
  it "should return information about a created milestone" do
47
- @milestone.project_id.should == 3
79
+ expect(@milestone.project_id).to eq(3)
48
80
  end
49
81
  end
50
82
 
51
83
  describe ".edit_milestone" do
52
84
  before do
53
85
  stub_put("/projects/3/milestones/33", "milestone")
54
- @milestone = Gitlab.edit_milestone(3, 33, :title => 'title')
86
+ @milestone = Gitlab.edit_milestone(3, 33, title: 'title')
55
87
  end
56
88
 
57
89
  it "should get the correct resource" do
58
- a_put("/projects/3/milestones/33").
59
- with(:body => {:title => 'title'}).should have_been_made
90
+ expect(a_put("/projects/3/milestones/33").
91
+ with(body: { title: 'title' })).to have_been_made
60
92
  end
61
93
 
62
94
  it "should return information about an edited milestone" do
63
- @milestone.project_id.should == 3
95
+ expect(@milestone.project_id).to eq(3)
64
96
  end
65
97
  end
66
98
  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
@@ -9,12 +9,12 @@ describe Gitlab::Client do
9
9
  end
10
10
 
11
11
  it "should get the correct resource" do
12
- a_get("/projects/3/notes").should have_been_made
12
+ expect(a_get("/projects/3/notes")).to have_been_made
13
13
  end
14
14
 
15
- it "should return an array of notes" do
16
- @notes.should be_an Array
17
- @notes.first.author.name.should == "John Smith"
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
18
  end
19
19
  end
20
20
 
@@ -25,12 +25,12 @@ describe Gitlab::Client do
25
25
  end
26
26
 
27
27
  it "should get the correct resource" do
28
- a_get("/projects/3/issues/7/notes").should have_been_made
28
+ expect(a_get("/projects/3/issues/7/notes")).to have_been_made
29
29
  end
30
30
 
31
- it "should return an array of notes" do
32
- @notes.should be_an Array
33
- @notes.first.author.name.should == "John Smith"
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
34
  end
35
35
  end
36
36
 
@@ -41,12 +41,28 @@ describe Gitlab::Client do
41
41
  end
42
42
 
43
43
  it "should get the correct resource" do
44
- a_get("/projects/3/snippets/7/notes").should have_been_made
44
+ expect(a_get("/projects/3/snippets/7/notes")).to have_been_made
45
45
  end
46
46
 
47
- it "should return an array of notes" do
48
- @notes.should be_an Array
49
- @notes.first.author.name.should == "John Smith"
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")
50
66
  end
51
67
  end
52
68
  end
@@ -59,12 +75,12 @@ describe Gitlab::Client do
59
75
  end
60
76
 
61
77
  it "should get the correct resource" do
62
- a_get("/projects/3/notes/1201").should have_been_made
78
+ expect(a_get("/projects/3/notes/1201")).to have_been_made
63
79
  end
64
80
 
65
81
  it "should return information about a note" do
66
- @note.body.should == "The solution is rather tricky"
67
- @note.author.name.should == "John Smith"
82
+ expect(@note.body).to eq("The solution is rather tricky")
83
+ expect(@note.author.name).to eq("John Smith")
68
84
  end
69
85
  end
70
86
 
@@ -75,12 +91,12 @@ describe Gitlab::Client do
75
91
  end
76
92
 
77
93
  it "should get the correct resource" do
78
- a_get("/projects/3/issues/7/notes/1201").should have_been_made
94
+ expect(a_get("/projects/3/issues/7/notes/1201")).to have_been_made
79
95
  end
80
96
 
81
97
  it "should return information about a note" do
82
- @note.body.should == "The solution is rather tricky"
83
- @note.author.name.should == "John Smith"
98
+ expect(@note.body).to eq("The solution is rather tricky")
99
+ expect(@note.author.name).to eq("John Smith")
84
100
  end
85
101
  end
86
102
 
@@ -91,12 +107,28 @@ describe Gitlab::Client do
91
107
  end
92
108
 
93
109
  it "should get the correct resource" do
94
- a_get("/projects/3/snippets/7/notes/1201").should have_been_made
110
+ expect(a_get("/projects/3/snippets/7/notes/1201")).to have_been_made
95
111
  end
96
112
 
97
113
  it "should return information about a note" do
98
- @note.body.should == "The solution is rather tricky"
99
- @note.author.name.should == "John Smith"
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")
100
132
  end
101
133
  end
102
134
  end
@@ -109,13 +141,13 @@ describe Gitlab::Client do
109
141
  end
110
142
 
111
143
  it "should get the correct resource" do
112
- a_post("/projects/3/notes").
113
- with(:body => {:body => 'The solution is rather tricky'}).should have_been_made
144
+ expect(a_post("/projects/3/notes").
145
+ with(body: { body: 'The solution is rather tricky' })).to have_been_made
114
146
  end
115
147
 
116
148
  it "should return information about a created note" do
117
- @note.body.should == "The solution is rather tricky"
118
- @note.author.name.should == "John Smith"
149
+ expect(@note.body).to eq("The solution is rather tricky")
150
+ expect(@note.author.name).to eq("John Smith")
119
151
  end
120
152
  end
121
153
 
@@ -126,13 +158,13 @@ describe Gitlab::Client do
126
158
  end
127
159
 
128
160
  it "should get the correct resource" do
129
- a_post("/projects/3/issues/7/notes").
130
- with(:body => {:body => 'The solution is rather tricky'}).should have_been_made
161
+ expect(a_post("/projects/3/issues/7/notes").
162
+ with(body: { body: 'The solution is rather tricky' })).to have_been_made
131
163
  end
132
164
 
133
165
  it "should return information about a created note" do
134
- @note.body.should == "The solution is rather tricky"
135
- @note.author.name.should == "John Smith"
166
+ expect(@note.body).to eq("The solution is rather tricky")
167
+ expect(@note.author.name).to eq("John Smith")
136
168
  end
137
169
  end
138
170
 
@@ -143,13 +175,30 @@ describe Gitlab::Client do
143
175
  end
144
176
 
145
177
  it "should get the correct resource" do
146
- a_post("/projects/3/snippets/7/notes").
147
- with(:body => {:body => 'The solution is rather tricky'}).should have_been_made
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
148
197
  end
149
198
 
150
199
  it "should return information about a created note" do
151
- @note.body.should == "The solution is rather tricky"
152
- @note.author.name.should == "John Smith"
200
+ expect(@note.body).to eq("The solution is rather tricky")
201
+ expect(@note.author.name).to eq("John Smith")
153
202
  end
154
203
  end
155
204
  end