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
@@ -2,9 +2,11 @@ require 'spec_helper'
2
2
 
3
3
  describe Gitlab::Client do
4
4
  it { should respond_to :repo_tags }
5
+ it { should respond_to :repo_create_tag }
5
6
  it { should respond_to :repo_branches }
6
7
  it { should respond_to :repo_branch }
7
- it { should respond_to :repo_commits }
8
+ it { should respond_to :repo_tree }
9
+ it { should respond_to :repo_compare }
8
10
 
9
11
  describe ".tags" do
10
12
  before do
@@ -13,61 +15,80 @@ describe Gitlab::Client do
13
15
  end
14
16
 
15
17
  it "should get the correct resource" do
16
- a_get("/projects/3/repository/tags").should have_been_made
18
+ expect(a_get("/projects/3/repository/tags")).to have_been_made
17
19
  end
18
20
 
19
- it "should return an array of repository tags" do
20
- @tags.should be_an Array
21
- @tags.first.name.should == "v2.8.2"
21
+ it "should return a paginated response of repository tags" do
22
+ expect(@tags).to be_a Gitlab::PaginatedResponse
23
+ expect(@tags.first.name).to eq("v2.8.2")
22
24
  end
23
25
  end
24
26
 
25
- describe ".branches" do
26
- before do
27
- stub_get("/projects/3/repository/branches", "project_branches")
28
- @branches = Gitlab.branches(3)
29
- end
27
+ describe ".create_tag" do
28
+ context "when lightweight" do
29
+ before do
30
+ stub_post("/projects/3/repository/tags", "project_tag_lightweight")
31
+ @tag = Gitlab.create_tag(3, 'v1.0.0', '2695effb5807a22ff3d138d593fd856244e155e7')
32
+ end
30
33
 
31
- it "should get the correct resource" do
32
- a_get("/projects/3/repository/branches").should have_been_made
34
+ it "should get the correct resource" do
35
+ expect(a_post("/projects/3/repository/tags")).to have_been_made
36
+ end
37
+
38
+ it "should return information about a new repository tag" do
39
+ expect(@tag.name).to eq("v1.0.0")
40
+ expect(@tag.message).to eq(nil)
41
+ end
33
42
  end
34
43
 
35
- it "should return an array of repository branches" do
36
- @branches.should be_an Array
37
- @branches.first.name.should == "api"
44
+ context "when annotated" do
45
+ before do
46
+ stub_post("/projects/3/repository/tags", "project_tag_annotated")
47
+ @tag = Gitlab.create_tag(3, 'v1.1.0', '2695effb5807a22ff3d138d593fd856244e155e7', 'Release 1.1.0')
48
+ end
49
+
50
+ it "should get the correct resource" do
51
+ expect(a_post("/projects/3/repository/tags")).to have_been_made
52
+ end
53
+
54
+ it "should return information about a new repository tag" do
55
+ expect(@tag.name).to eq("v1.1.0")
56
+ expect(@tag.message).to eq("Release 1.1.0")
57
+ end
38
58
  end
39
59
  end
40
60
 
41
- describe ".branch" do
61
+ describe ".tree" do
42
62
  before do
43
- stub_get("/projects/3/repository/branches/api", "project_branch")
44
- @branch = Gitlab.branch(3, "api")
63
+ stub_get("/projects/3/repository/tree", "tree")
64
+ @tree = Gitlab.tree(3)
45
65
  end
46
66
 
47
67
  it "should get the correct resource" do
48
- a_get("/projects/3/repository/branches/api").should have_been_made
68
+ expect(a_get("/projects/3/repository/tree")).to have_been_made
49
69
  end
50
70
 
51
- it "should return information about a repository branch" do
52
- @branch.name.should == "api"
71
+ it "should return a paginated response of repository tree files (root level)" do
72
+ expect(@tree).to be_a Gitlab::PaginatedResponse
73
+ expect(@tree.first.name).to eq("app")
53
74
  end
54
75
  end
55
76
 
56
- describe ".commits" do
77
+ describe ".compare" do
57
78
  before do
58
- stub_get("/projects/3/repository/commits", "project_commits").
59
- with(:query => {:ref_name => "api"})
60
- @commits = Gitlab.commits(3, :ref_name => "api")
79
+ stub_get("/projects/3/repository/compare", "compare_merge_request_diff").
80
+ with(query: { from: "master", to: "feature" })
81
+ @diff = Gitlab.compare(3, 'master', 'feature')
61
82
  end
62
83
 
63
84
  it "should get the correct resource" do
64
- a_get("/projects/3/repository/commits").
65
- with(:query => {:ref_name => "api"}).should have_been_made
85
+ expect(a_get("/projects/3/repository/compare").
86
+ with(query: { from: "master", to: "feature" })).to have_been_made
66
87
  end
67
88
 
68
- it "should return an array of repository commits" do
69
- @commits.should be_an Array
70
- @commits.first.id.should == "f7dd067490fe57505f7226c3b54d3127d2f7fd46"
89
+ it "should get diffs of a merge request" do
90
+ expect(@diff.diffs).to be_kind_of Array
91
+ expect(@diff.diffs.last["new_path"]).to eq "files/js/application.js"
71
92
  end
72
93
  end
73
94
  end
@@ -0,0 +1,77 @@
1
+ require "spec_helper"
2
+
3
+ describe Gitlab::Client do
4
+ describe ".file_contents" do
5
+ before do
6
+ stub_get("/projects/3/repository/files/Gemfile/raw?ref=master", "raw_file")
7
+ @file_contents = Gitlab.file_contents(3, "Gemfile")
8
+ end
9
+
10
+ it "should get the correct resource" do
11
+ expect(a_get("/projects/3/repository/files/Gemfile/raw?ref=master")).to have_been_made
12
+ end
13
+
14
+ it "should return file contents" do
15
+ expect(@file_contents).to eq("source 'https://rubygems.org'\ngem 'rails', '4.1.2'\n")
16
+ end
17
+ end
18
+
19
+ describe ".get_file" do
20
+ before do
21
+ stub_get("/projects/3/repository/files/README%2Emd?ref=master", "get_repository_file")
22
+ @file = Gitlab.get_file(3, 'README.md', 'master')
23
+ end
24
+
25
+ it "should create the correct resource" do
26
+ expect(a_get("/projects/3/repository/files/README%2Emd?ref=master")).to have_been_made
27
+ end
28
+
29
+ it "should return the base64 encoded file" do
30
+ expect(@file.file_path).to eq "README.md"
31
+ expect(@file.ref).to eq "master"
32
+ expect(@file.content).to eq "VGhpcyBpcyBhICpSRUFETUUqIQ==\n"
33
+ end
34
+ end
35
+
36
+ describe ".create_file" do
37
+ let!(:request_stub) { stub_post("/projects/3/repository/files", "repository_file") }
38
+ let!(:file) { Gitlab.create_file(3, "path", "branch", "content", "commit message") }
39
+
40
+ it "should create the correct resource" do
41
+ expect(request_stub).to have_been_made
42
+ end
43
+
44
+ it "should return information about the new file" do
45
+ expect(file.file_path).to eq "path"
46
+ expect(file.branch_name).to eq "branch"
47
+ end
48
+ end
49
+
50
+ describe ".edit_file" do
51
+ let!(:request_stub) { stub_put("/projects/3/repository/files", "repository_file") }
52
+ let!(:file) { Gitlab.edit_file(3, "path", "branch", "content", "commit message") }
53
+
54
+ it "should create the correct resource" do
55
+ expect(request_stub).to have_been_made
56
+ end
57
+
58
+ it "should return information about the new file" do
59
+ expect(file.file_path).to eq "path"
60
+ expect(file.branch_name).to eq "branch"
61
+ end
62
+ end
63
+
64
+ describe ".remove_file" do
65
+ let!(:request_stub) { stub_delete("/projects/3/repository/files", "repository_file") }
66
+ let!(:file) { Gitlab.remove_file(3, "path", "branch", "commit message") }
67
+
68
+ it "should create the correct resource" do
69
+ expect(request_stub).to have_been_made
70
+ end
71
+
72
+ it "should return information about the new file" do
73
+ expect(file.file_path).to eq "path"
74
+ expect(file.branch_name).to eq "branch"
75
+ end
76
+ end
77
+ end
@@ -0,0 +1,185 @@
1
+ require 'spec_helper'
2
+
3
+ describe Gitlab::Client do
4
+
5
+ describe ".runners" do
6
+ before do
7
+ stub_get("/runners", "runners")
8
+ end
9
+
10
+ context 'without scope' do
11
+ before do
12
+ @runner = Gitlab.runners
13
+ end
14
+
15
+ it "should get the correct resource" do
16
+ expect(a_get("/runners")).to have_been_made
17
+ end
18
+
19
+ it "should return a paginated response of runners" do
20
+ expect(@runner).to be_a Gitlab::PaginatedResponse
21
+ expect(@runner.first.id).to eq(6)
22
+ expect(@runner.first.description).to eq('test-1-20150125')
23
+ end
24
+ end
25
+
26
+ context 'with scope' do
27
+ before do
28
+ stub_get("/runners?scope=online", "runners")
29
+ @runner = Gitlab.runners({scope: :online})
30
+ end
31
+
32
+ it "should get the correct resource" do
33
+ expect(a_get("/runners").with(query: { scope: :online })).to have_been_made
34
+ end
35
+
36
+ it "should return a paginated response of runners" do
37
+ expect(@runner).to be_a Gitlab::PaginatedResponse
38
+ expect(@runner.first.id).to eq(6)
39
+ expect(@runner.first.description).to eq('test-1-20150125')
40
+ end
41
+ end
42
+
43
+ end
44
+
45
+ describe ".all_runners" do
46
+ before do
47
+ stub_get("/runners/all", "runners")
48
+ end
49
+
50
+ context 'without scope' do
51
+ before do
52
+ @runner = Gitlab.all_runners
53
+ end
54
+
55
+ it "should get the correct resource" do
56
+ expect(a_get("/runners/all")).to have_been_made
57
+ end
58
+
59
+ it "should return a paginated response of runners" do
60
+ expect(@runner).to be_a Gitlab::PaginatedResponse
61
+ expect(@runner.first.id).to eq(6)
62
+ expect(@runner.first.description).to eq('test-1-20150125')
63
+ end
64
+ end
65
+
66
+ context 'with scope' do
67
+ before do
68
+ stub_get("/runners/all?scope=online", "runners")
69
+ @runner = Gitlab.all_runners({scope: :online})
70
+ end
71
+
72
+ it "should get the correct resource" do
73
+ expect(a_get("/runners/all").with(query: { scope: :online })).to have_been_made
74
+ end
75
+
76
+ it "should return a paginated response of runners" do
77
+ expect(@runner).to be_a Gitlab::PaginatedResponse
78
+ expect(@runner.first.id).to eq(6)
79
+ expect(@runner.first.description).to eq('test-1-20150125')
80
+ end
81
+ end
82
+ end
83
+
84
+ describe ".runner" do
85
+ before do
86
+ stub_get("/runners/6", "runner")
87
+ @runners = Gitlab.runner(6)
88
+ end
89
+
90
+ it "should get the correct resource" do
91
+ expect(a_get("/runners/6")).to have_been_made
92
+ end
93
+
94
+ it "should return a response of a runner" do
95
+ expect(@runners).to be_a Gitlab::ObjectifiedHash
96
+ expect(@runners.id).to eq(6)
97
+ expect(@runners.description).to eq('test-1-20150125')
98
+ end
99
+ end
100
+
101
+ describe ".update_runner" do
102
+ before do
103
+ stub_put("/runners/6", "runner_edit").with(query: { description: "abcefg" })
104
+ @runner = Gitlab.update_runner(6, description: "abcefg" )
105
+ end
106
+
107
+ it "should get the correct resource" do
108
+ expect(a_put("/runners/6").with(query: { description: "abcefg" })).to have_been_made
109
+ end
110
+
111
+ it "should return an updated response of a runner" do
112
+ expect(@runner).to be_a Gitlab::ObjectifiedHash
113
+ expect(@runner.description).to eq('abcefg')
114
+ end
115
+ end
116
+
117
+ describe ".delete_runner" do
118
+ before do
119
+ stub_delete("/runners/6", "runner_delete")
120
+ @runner = Gitlab.delete_runner(6)
121
+ end
122
+
123
+ it "should get the correct resource" do
124
+ expect(a_delete("/runners/6")).to have_been_made
125
+ end
126
+
127
+ it "should return a response of the deleted runner" do
128
+ expect(@runner).to be_a Gitlab::ObjectifiedHash
129
+ expect(@runner.id).to eq(6)
130
+ end
131
+ end
132
+
133
+ describe ".project_runners" do
134
+ before do
135
+ stub_get("/projects/1/runners", "project_runners")
136
+ @runners = Gitlab.project_runners(1)
137
+ end
138
+
139
+ it "should get the correct resource" do
140
+ expect(a_get("/projects/1/runners")).to have_been_made
141
+ end
142
+
143
+ it "should return a paginated response of runners" do
144
+ expect(@runners).to be_a Gitlab::PaginatedResponse
145
+ expect(@runners.first.id).to eq(8)
146
+ expect(@runners.first.description).to eq('test-2-20150125')
147
+ end
148
+ end
149
+
150
+ describe ".project_enable_runner" do
151
+ before do
152
+ stub_post("/projects/1/runners", "runner")
153
+ @runner = Gitlab.project_enable_runner(1, 6)
154
+ end
155
+
156
+ it "should get the correct resource" do
157
+ expect(a_post("/projects/1/runners")).to have_been_made
158
+ end
159
+
160
+ it "should return a response of the enabled runner" do
161
+ expect(@runner).to be_a Gitlab::ObjectifiedHash
162
+ expect(@runner.id).to eq(6)
163
+ expect(@runner.description).to eq('test-1-20150125')
164
+ end
165
+ end
166
+
167
+ describe ".project_disable_runner" do
168
+ before do
169
+ stub_delete("/projects/1/runners/6", "runner")
170
+ @runner = Gitlab.project_disable_runner(1, 6)
171
+ end
172
+
173
+ it "should get the correct resource" do
174
+ expect(a_delete("/projects/1/runners/6")).to have_been_made
175
+ end
176
+
177
+ it "should return a response of the disabled runner" do
178
+ expect(@runner).to be_a Gitlab::ObjectifiedHash
179
+ expect(@runner.id).to eq(6)
180
+ expect(@runner.description).to eq('test-1-20150125')
181
+ end
182
+ end
183
+
184
+
185
+ end
@@ -0,0 +1,55 @@
1
+ require 'spec_helper'
2
+
3
+ describe Gitlab::Client do
4
+ describe ".service" do
5
+ before do
6
+ stub_get("/projects/3/services/redmine", "service")
7
+ @service = Gitlab.service(3, :redmine)
8
+ end
9
+
10
+ it "should get the correct resource" do
11
+ expect(a_get("/projects/3/services/redmine")).to have_been_made
12
+ end
13
+
14
+ it "should return a information about a service of project" do
15
+ expect(@service.id).to eq 38
16
+ expect(@service.title).to eq("Redmine")
17
+ expect(@service.properties.project_url).to eq("https://example.com/projects/test_project/issue")
18
+ end
19
+ end
20
+
21
+ describe ".change_service" do
22
+ before do
23
+ stub_put("/projects/3/services/redmine", "service")
24
+ @service = Gitlab.change_service(3, :redmine, new_issue_url: 'https://example.com/projects/test_project/issues/new',
25
+ project_url: 'https://example.com/projects/test_project/issues',
26
+ issues_url: 'https://example.com/issues/:id')
27
+ end
28
+
29
+ it "should get the correct resource" do
30
+ body = {new_issue_url: 'https://example.com/projects/test_project/issues/new',
31
+ project_url: 'https://example.com/projects/test_project/issues',
32
+ issues_url: 'https://example.com/issues/:id'}
33
+ expect(a_put("/projects/3/services/redmine").with(body: body)).to have_been_made
34
+ end
35
+
36
+ it "should return information about a new service" do
37
+ expect(@service).to be_truthy
38
+ end
39
+ end
40
+
41
+ describe ".delete_servoce" do
42
+ before do
43
+ stub_delete("/projects/3/services/redmine", "service")
44
+ @service = Gitlab.delete_service(3, :redmine)
45
+ end
46
+
47
+ it "should get the correct resource" do
48
+ expect(a_delete("/projects/3/services/redmine")).to have_been_made
49
+ end
50
+
51
+ it "should return information about a deleted service" do
52
+ expect(@service).to be_truthy
53
+ end
54
+ end
55
+ 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/snippets").should have_been_made
11
+ expect(a_get("/projects/3/snippets")).to have_been_made
12
12
  end
13
13
 
14
- it "should return an array of project's snippets" do
15
- @snippets.should be_an Array
16
- @snippets.first.file_name.should == "mailer_test.rb"
14
+ it "should return a paginated response of project's snippets" do
15
+ expect(@snippets).to be_a Gitlab::PaginatedResponse
16
+ expect(@snippets.first.file_name).to eq("mailer_test.rb")
17
17
  end
18
18
  end
19
19
 
@@ -24,46 +24,46 @@ describe Gitlab::Client do
24
24
  end
25
25
 
26
26
  it "should get the correct resource" do
27
- a_get("/projects/3/snippets/1").should have_been_made
27
+ expect(a_get("/projects/3/snippets/1")).to have_been_made
28
28
  end
29
29
 
30
30
  it "should return information about a snippet" do
31
- @snippet.file_name.should == "mailer_test.rb"
32
- @snippet.author.name.should == "John Smith"
31
+ expect(@snippet.file_name).to eq("mailer_test.rb")
32
+ expect(@snippet.author.name).to eq("John Smith")
33
33
  end
34
34
  end
35
35
 
36
36
  describe ".create_snippet" do
37
37
  before do
38
38
  stub_post("/projects/3/snippets", "snippet")
39
- @snippet = Gitlab.create_snippet(3, {:title => 'API', :file_name => 'api.rb', :code => 'code'})
39
+ @snippet = Gitlab.create_snippet(3, title: 'API', file_name: 'api.rb', code: 'code')
40
40
  end
41
41
 
42
42
  it "should get the correct resource" do
43
- body = {:title => 'API', :file_name => 'api.rb', :code => 'code'}
44
- a_post("/projects/3/snippets").with(:body => body).should have_been_made
43
+ body = { title: 'API', file_name: 'api.rb', code: 'code' }
44
+ expect(a_post("/projects/3/snippets").with(body: body)).to have_been_made
45
45
  end
46
46
 
47
47
  it "should return information about a new snippet" do
48
- @snippet.file_name.should == "mailer_test.rb"
49
- @snippet.author.name.should == "John Smith"
48
+ expect(@snippet.file_name).to eq("mailer_test.rb")
49
+ expect(@snippet.author.name).to eq("John Smith")
50
50
  end
51
51
  end
52
52
 
53
53
  describe ".edit_snippet" do
54
54
  before do
55
55
  stub_put("/projects/3/snippets/1", "snippet")
56
- @snippet = Gitlab.edit_snippet(3, 1, :file_name => 'mailer_test.rb')
56
+ @snippet = Gitlab.edit_snippet(3, 1, file_name: 'mailer_test.rb')
57
57
  end
58
58
 
59
59
  it "should get the correct resource" do
60
- a_put("/projects/3/snippets/1").
61
- with(:body => {:file_name => 'mailer_test.rb'}).should have_been_made
60
+ expect(a_put("/projects/3/snippets/1").
61
+ with(body: { file_name: 'mailer_test.rb' })).to have_been_made
62
62
  end
63
63
 
64
64
  it "should return information about an edited snippet" do
65
- @snippet.file_name.should == "mailer_test.rb"
66
- @snippet.author.name.should == "John Smith"
65
+ expect(@snippet.file_name).to eq("mailer_test.rb")
66
+ expect(@snippet.author.name).to eq("John Smith")
67
67
  end
68
68
  end
69
69
 
@@ -74,12 +74,27 @@ describe Gitlab::Client do
74
74
  end
75
75
 
76
76
  it "should get the correct resource" do
77
- a_delete("/projects/3/snippets/1").should have_been_made
77
+ expect(a_delete("/projects/3/snippets/1")).to have_been_made
78
78
  end
79
79
 
80
80
  it "should return information about a deleted snippet" do
81
- @snippet.file_name.should == "mailer_test.rb"
82
- @snippet.author.name.should == "John Smith"
81
+ expect(@snippet.file_name).to eq("mailer_test.rb")
82
+ expect(@snippet.author.name).to eq("John Smith")
83
+ end
84
+ end
85
+
86
+ describe ".snippet_content" do
87
+ before do
88
+ stub_get("/projects/3/snippets/1/raw", "snippet_content")
89
+ @snippet_content = Gitlab.snippet_content(3, 1)
90
+ end
91
+
92
+ it "should get the correct resource" do
93
+ expect(a_get("/projects/3/snippets/1/raw")).to have_been_made
94
+ end
95
+
96
+ it "should return raw content of a snippet" do
97
+ expect(@snippet_content).to eq("#!/usr/bin/env ruby\n\nputs \"Cool snippet!\"\n")
83
98
  end
84
99
  end
85
100
  end