gitlab 4.2.0 → 4.3.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.
- checksums.yaml +5 -5
- data/.rubocop.yml +33 -0
- data/.travis.yml +8 -3
- data/README.md +7 -7
- data/Rakefile +11 -3
- data/gitlab.gemspec +11 -11
- data/lib/gitlab.rb +2 -2
- data/lib/gitlab/api.rb +2 -1
- data/lib/gitlab/cli.rb +2 -6
- data/lib/gitlab/cli_helpers.rb +18 -20
- data/lib/gitlab/client.rb +8 -5
- data/lib/gitlab/client/branches.rb +4 -4
- data/lib/gitlab/client/build_variables.rb +64 -2
- data/lib/gitlab/client/deployments.rb +32 -0
- data/lib/gitlab/client/groups.rb +49 -0
- data/lib/gitlab/client/issues.rb +71 -0
- data/lib/gitlab/client/merge_requests.rb +1 -0
- data/lib/gitlab/client/pipeline_schedules.rb +133 -0
- data/lib/gitlab/client/pipeline_triggers.rb +2 -2
- data/lib/gitlab/client/projects.rb +1 -1
- data/lib/gitlab/client/repository_files.rb +2 -2
- data/lib/gitlab/client/users.rb +5 -5
- data/lib/gitlab/configuration.rb +2 -2
- data/lib/gitlab/error.rb +10 -2
- data/lib/gitlab/file_response.rb +1 -1
- data/lib/gitlab/help.rb +5 -6
- data/lib/gitlab/page_links.rb +2 -2
- data/lib/gitlab/request.rb +34 -50
- data/lib/gitlab/shell.rb +5 -8
- data/lib/gitlab/version.rb +1 -1
- data/spec/fixtures/deployment.json +57 -0
- data/spec/fixtures/deployments.json +116 -0
- data/spec/fixtures/group_edit.json +14 -0
- data/spec/fixtures/group_subgroups.json +16 -0
- data/spec/fixtures/pipeline_schedule.json +32 -0
- data/spec/fixtures/pipeline_schedule_create.json +21 -0
- data/spec/fixtures/pipeline_schedule_update.json +26 -0
- data/spec/fixtures/pipeline_schedule_variable.json +5 -0
- data/spec/fixtures/pipeline_schedule_variable_update.json +5 -0
- data/spec/fixtures/pipeline_schedules.json +22 -0
- data/spec/gitlab/api_spec.rb +11 -0
- data/spec/gitlab/cli_helpers_spec.rb +14 -15
- data/spec/gitlab/cli_spec.rb +11 -11
- data/spec/gitlab/client/award_emojis_spec.rb +55 -55
- data/spec/gitlab/client/boards_spec.rb +12 -12
- data/spec/gitlab/client/branches_spec.rb +22 -22
- data/spec/gitlab/client/build_variables_spec.rb +93 -10
- data/spec/gitlab/client/builds_spec.rb +36 -36
- data/spec/gitlab/client/commits_spec.rb +21 -21
- data/spec/gitlab/client/deployments_spec.rb +38 -0
- data/spec/gitlab/client/environments_spec.rb +18 -18
- data/spec/gitlab/client/groups_spec.rb +73 -22
- data/spec/gitlab/client/issues_spec.rb +121 -22
- data/spec/gitlab/client/jobs_spec.rb +13 -13
- data/spec/gitlab/client/keys_spec.rb +2 -2
- data/spec/gitlab/client/labels_spec.rb +12 -12
- data/spec/gitlab/client/merge_requests_spec.rb +23 -23
- data/spec/gitlab/client/milestones_spec.rb +12 -12
- data/spec/gitlab/client/namespaces_spec.rb +3 -3
- data/spec/gitlab/client/notes_spec.rb +40 -40
- data/spec/gitlab/client/pipeline_schedules_spec.rb +158 -0
- data/spec/gitlab/client/pipeline_triggers_spec.rb +17 -17
- data/spec/gitlab/client/pipelines_spec.rb +22 -22
- data/spec/gitlab/client/projects_spec.rb +75 -75
- data/spec/gitlab/client/repositories_spec.rb +16 -16
- data/spec/gitlab/client/repository_files_spec.rb +10 -10
- data/spec/gitlab/client/runners_spec.rb +20 -22
- data/spec/gitlab/client/services_spec.rb +6 -6
- data/spec/gitlab/client/snippets_spec.rb +12 -12
- data/spec/gitlab/client/system_hooks_spec.rb +12 -12
- data/spec/gitlab/client/tags_spec.rb +19 -20
- data/spec/gitlab/client/todos_spec.rb +12 -12
- data/spec/gitlab/client/users_spec.rb +49 -49
- data/spec/gitlab/error_spec.rb +50 -23
- data/spec/gitlab/file_response_spec.rb +6 -6
- data/spec/gitlab/help_spec.rb +5 -5
- data/spec/gitlab/objectified_hash_spec.rb +8 -8
- data/spec/gitlab/page_links_spec.rb +1 -1
- data/spec/gitlab/paginated_response_spec.rb +4 -4
- data/spec/gitlab/request_spec.rb +19 -19
- data/spec/gitlab/shell_spec.rb +12 -12
- data/spec/gitlab_spec.rb +13 -14
- data/spec/spec_helper.rb +10 -45
- metadata +46 -3
@@ -0,0 +1,158 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Gitlab::Client do
|
4
|
+
describe ".pipeline_schedules" do
|
5
|
+
before do
|
6
|
+
stub_get("/projects/3/pipeline_schedules", "pipeline_schedules")
|
7
|
+
@pipeline_schedules = Gitlab.pipeline_schedules(3)
|
8
|
+
end
|
9
|
+
|
10
|
+
it "gets the correct resource" do
|
11
|
+
expect(a_get("/projects/3/pipeline_schedules")).to have_been_made
|
12
|
+
end
|
13
|
+
|
14
|
+
it "returns a response of project's pipeline schedules" do
|
15
|
+
expect(@pipeline_schedules).to be_a Gitlab::PaginatedResponse
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
describe ".pipeline_schedule" do
|
20
|
+
before do
|
21
|
+
stub_get("/projects/3/pipeline_schedules/5", "pipeline_schedule")
|
22
|
+
@pipeline_schedule = Gitlab.pipeline_schedule(3, 5)
|
23
|
+
end
|
24
|
+
|
25
|
+
it "gets the correct resource" do
|
26
|
+
expect(a_get("/projects/3/pipeline_schedules/5")).to have_been_made
|
27
|
+
end
|
28
|
+
|
29
|
+
it "returns a response of project's pipeline schedules" do
|
30
|
+
expect(@pipeline_schedule).to be_a Gitlab::ObjectifiedHash
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe ".create_pipeline_schedule" do
|
35
|
+
before do
|
36
|
+
stub_post("/projects/3/pipeline_schedules", "pipeline_schedule_create")
|
37
|
+
@pipeline_schedule_create = Gitlab.create_pipeline_schedule(3)
|
38
|
+
end
|
39
|
+
|
40
|
+
it "gets the correct resource" do
|
41
|
+
expect(a_post("/projects/3/pipeline_schedules")).to have_been_made
|
42
|
+
end
|
43
|
+
|
44
|
+
it "returns a single pipeline schedule" do
|
45
|
+
expect(@pipeline_schedule_create).to be_a Gitlab::ObjectifiedHash
|
46
|
+
end
|
47
|
+
|
48
|
+
it "returns information about a pipeline schedule" do
|
49
|
+
expect(@pipeline_schedule_create.owner.name).to eq("Administrator")
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
describe ".edit_pipeline_schedule" do
|
54
|
+
before do
|
55
|
+
stub_put("/projects/3/pipeline_schedules/13", "pipeline_schedule_update")
|
56
|
+
@pipeline_schedule_update = Gitlab.edit_pipeline_schedule(3, 13)
|
57
|
+
end
|
58
|
+
|
59
|
+
it "gets the correct resource" do
|
60
|
+
expect(a_put("/projects/3/pipeline_schedules/13")).to have_been_made
|
61
|
+
end
|
62
|
+
|
63
|
+
it "returns a single pipeline schedule" do
|
64
|
+
expect(@pipeline_schedule_update).to be_a Gitlab::ObjectifiedHash
|
65
|
+
end
|
66
|
+
|
67
|
+
it "returns information about a pipeline schedule" do
|
68
|
+
expect(@pipeline_schedule_update.owner.name).to eq("Administrator")
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
describe ".pipeline_schedule_take_ownership" do
|
73
|
+
before do
|
74
|
+
stub_post("/projects/3/pipeline_schedules/13/take_ownership", "pipeline_schedule")
|
75
|
+
@pipeline_schedule = Gitlab.pipeline_schedule_take_ownership(3, 13)
|
76
|
+
end
|
77
|
+
|
78
|
+
it "gets the correct resource" do
|
79
|
+
expect(a_post("/projects/3/pipeline_schedules/13/take_ownership")).to have_been_made
|
80
|
+
end
|
81
|
+
|
82
|
+
it "returns information about the pipeline schedule" do
|
83
|
+
expect(@pipeline_schedule.created_at).to eq("2017-05-19T13:31:08.849Z")
|
84
|
+
expect(@pipeline_schedule.description).to eq("Test schedule pipeline")
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
describe ".delete_pipeline_schedule" do
|
89
|
+
before do
|
90
|
+
stub_delete("/projects/3/pipeline_schedules/13", "pipeline_schedule")
|
91
|
+
@pipeline_schedule = Gitlab.delete_pipeline_schedule(3,13)
|
92
|
+
end
|
93
|
+
|
94
|
+
it "gets the correct resource" do
|
95
|
+
expect(a_delete("/projects/3/pipeline_schedules/13")).to have_been_made
|
96
|
+
end
|
97
|
+
|
98
|
+
it "returns a single pipeline" do
|
99
|
+
expect(@pipeline_schedule).to be_a Gitlab::ObjectifiedHash
|
100
|
+
end
|
101
|
+
|
102
|
+
it "returns information about the deleted pipeline" do
|
103
|
+
# expect(@pipeline_schedule.id).to eq(13)
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
describe ".create_pipeline_schedule_variable" do
|
108
|
+
before do
|
109
|
+
stub_post("/projects/3/pipeline_schedules/13/variables?key=NEW%20VARIABLE&value=new%20value", "pipeline_schedule_variable")
|
110
|
+
@pipeline_schedule_variable = Gitlab.create_pipeline_schedule_variable(3, 13, {
|
111
|
+
key: "NEW VARIABLE",
|
112
|
+
value: "new value"
|
113
|
+
})
|
114
|
+
end
|
115
|
+
|
116
|
+
it "gets the correct resource" do
|
117
|
+
expect(a_post("/projects/3/pipeline_schedules/13/variables?key=NEW%20VARIABLE&value=new%20value")).to have_been_made
|
118
|
+
end
|
119
|
+
|
120
|
+
it "returns a single variable" do
|
121
|
+
expect(@pipeline_schedule_variable).to be_a Gitlab::ObjectifiedHash
|
122
|
+
end
|
123
|
+
|
124
|
+
it "returns the created variable" do
|
125
|
+
expect(@pipeline_schedule_variable.value).to eq("new value")
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
describe ".edit_pipeline_schedule_variable" do
|
130
|
+
before do
|
131
|
+
stub_put("/projects/3/pipeline_schedules/13/variables/NEW%20VARIABLE?value=update%20value", "pipeline_schedule_variable_update")
|
132
|
+
@pipeline_schedule_variable = Gitlab.edit_pipeline_schedule_variable(3, 13, "NEW VARIABLE", { value: "update value" })
|
133
|
+
end
|
134
|
+
|
135
|
+
it "returns a single variable" do
|
136
|
+
expect(@pipeline_schedule_variable).to be_a Gitlab::ObjectifiedHash
|
137
|
+
end
|
138
|
+
|
139
|
+
it "has the updated value" do
|
140
|
+
expect(@pipeline_schedule_variable.value).to eq("update value")
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
describe ".delete_pipeline_schedule_variable" do
|
145
|
+
before do
|
146
|
+
stub_delete("/projects/3/pipeline_schedules/13/variables/NEW%20VARIABLE", "pipeline_schedule_variable")
|
147
|
+
@pipeline_schedule_variable = Gitlab.delete_pipeline_schedule_variable(3, 13, "NEW VARIABLE")
|
148
|
+
end
|
149
|
+
|
150
|
+
it "returns a single variable" do
|
151
|
+
expect(@pipeline_schedule_variable).to be_a Gitlab::ObjectifiedHash
|
152
|
+
end
|
153
|
+
|
154
|
+
it "has the value of the deleted variable" do
|
155
|
+
expect(@pipeline_schedule_variable.value).to eq("new value")
|
156
|
+
end
|
157
|
+
end
|
158
|
+
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Gitlab::Client do
|
4
|
-
it {
|
4
|
+
it { is_expected.to respond_to :delete_trigger }
|
5
5
|
|
6
6
|
describe ".triggers" do
|
7
7
|
before do
|
@@ -9,11 +9,11 @@ describe Gitlab::Client do
|
|
9
9
|
@triggers = Gitlab.triggers(3)
|
10
10
|
end
|
11
11
|
|
12
|
-
it "
|
12
|
+
it "gets the correct resource" do
|
13
13
|
expect(a_get("/projects/3/triggers")).to have_been_made
|
14
14
|
end
|
15
15
|
|
16
|
-
it "
|
16
|
+
it "returns an array of project's triggers" do
|
17
17
|
expect(@triggers).to be_a Gitlab::PaginatedResponse
|
18
18
|
expect(@triggers.first.token).to eq("6d056f63e50fe6f8c5f8f4aa10edb7")
|
19
19
|
end
|
@@ -25,11 +25,11 @@ describe Gitlab::Client do
|
|
25
25
|
@trigger = Gitlab.trigger(3, 10)
|
26
26
|
end
|
27
27
|
|
28
|
-
it "
|
28
|
+
it "gets the correct resource" do
|
29
29
|
expect(a_get("/projects/3/triggers/10")).to have_been_made
|
30
30
|
end
|
31
31
|
|
32
|
-
it "
|
32
|
+
it "returns information about a trigger" do
|
33
33
|
expect(@trigger.created_at).to eq("2016-01-07T09:53:58.235Z")
|
34
34
|
expect(@trigger.token).to eq("6d056f63e50fe6f8c5f8f4aa10edb7")
|
35
35
|
end
|
@@ -41,12 +41,12 @@ describe Gitlab::Client do
|
|
41
41
|
@trigger = Gitlab.create_trigger(3, "my description")
|
42
42
|
end
|
43
43
|
|
44
|
-
it "
|
44
|
+
it "gets the correct resource" do
|
45
45
|
expect(a_post("/projects/3/triggers").
|
46
46
|
with(body: { description: "my description" })).to have_been_made
|
47
47
|
end
|
48
48
|
|
49
|
-
it "
|
49
|
+
it "returns information about a new trigger" do
|
50
50
|
expect(@trigger.created_at).to eq("2016-01-07T09:53:58.235Z")
|
51
51
|
expect(@trigger.token).to eq("6d056f63e50fe6f8c5f8f4aa10edb7")
|
52
52
|
end
|
@@ -58,12 +58,12 @@ describe Gitlab::Client do
|
|
58
58
|
@trigger = Gitlab.update_trigger(3, 1, description: "my description")
|
59
59
|
end
|
60
60
|
|
61
|
-
it "
|
61
|
+
it "gets the correct resource" do
|
62
62
|
expect(a_put("/projects/3/triggers/1").
|
63
63
|
with(body: { description: "my description" })).to have_been_made
|
64
64
|
end
|
65
65
|
|
66
|
-
it "
|
66
|
+
it "returns information about the trigger" do
|
67
67
|
expect(@trigger.created_at).to eq("2016-01-07T09:53:58.235Z")
|
68
68
|
expect(@trigger.token).to eq("6d056f63e50fe6f8c5f8f4aa10edb7")
|
69
69
|
end
|
@@ -75,11 +75,11 @@ describe Gitlab::Client do
|
|
75
75
|
@trigger = Gitlab.trigger_take_ownership(3, 1)
|
76
76
|
end
|
77
77
|
|
78
|
-
it "
|
78
|
+
it "gets the correct resource" do
|
79
79
|
expect(a_post("/projects/3/triggers/1/take_ownership")).to have_been_made
|
80
80
|
end
|
81
81
|
|
82
|
-
it "
|
82
|
+
it "returns information about the trigger" do
|
83
83
|
expect(@trigger.created_at).to eq("2016-01-07T09:53:58.235Z")
|
84
84
|
expect(@trigger.token).to eq("6d056f63e50fe6f8c5f8f4aa10edb7")
|
85
85
|
end
|
@@ -91,7 +91,7 @@ describe Gitlab::Client do
|
|
91
91
|
@trigger = Gitlab.remove_trigger(3, 10)
|
92
92
|
end
|
93
93
|
|
94
|
-
it "
|
94
|
+
it "gets the correct resource" do
|
95
95
|
expect(a_delete("/projects/3/triggers/10")).to have_been_made
|
96
96
|
end
|
97
97
|
end
|
@@ -107,7 +107,7 @@ describe Gitlab::Client do
|
|
107
107
|
Gitlab.private_token = nil
|
108
108
|
end
|
109
109
|
|
110
|
-
it "
|
110
|
+
it "does not raise Error::MissingCredentials" do
|
111
111
|
expect { Gitlab.run_trigger(3, "7b9148c158980bbd9bcea92c17522d", "master", {a: 10}) }.to_not raise_error
|
112
112
|
end
|
113
113
|
|
@@ -121,7 +121,7 @@ describe Gitlab::Client do
|
|
121
121
|
@trigger = Gitlab.run_trigger(3, "7b9148c158980bbd9bcea92c17522d", "master")
|
122
122
|
end
|
123
123
|
|
124
|
-
it "
|
124
|
+
it "gets the correct resource" do
|
125
125
|
expect(a_request(:post, "#{Gitlab.endpoint}/projects/3/trigger/pipeline").
|
126
126
|
with(body: {
|
127
127
|
token: "7b9148c158980bbd9bcea92c17522d",
|
@@ -129,7 +129,7 @@ describe Gitlab::Client do
|
|
129
129
|
})).to have_been_made
|
130
130
|
end
|
131
131
|
|
132
|
-
it "
|
132
|
+
it "returns information about the triggered build" do
|
133
133
|
expect(@trigger.id).to eq(8)
|
134
134
|
end
|
135
135
|
end
|
@@ -139,7 +139,7 @@ describe Gitlab::Client do
|
|
139
139
|
@trigger = Gitlab.run_trigger(3, "7b9148c158980bbd9bcea92c17522d", "master", {a: 10})
|
140
140
|
end
|
141
141
|
|
142
|
-
it "
|
142
|
+
it "gets the correct resource" do
|
143
143
|
expect(a_request(:post, "#{Gitlab.endpoint}/projects/3/trigger/pipeline").
|
144
144
|
with(body: {
|
145
145
|
token: "7b9148c158980bbd9bcea92c17522d",
|
@@ -148,7 +148,7 @@ describe Gitlab::Client do
|
|
148
148
|
})).to have_been_made
|
149
149
|
end
|
150
150
|
|
151
|
-
it "
|
151
|
+
it "returns information about the triggered build" do
|
152
152
|
expect(@trigger.id).to eq(8)
|
153
153
|
expect(@trigger.variables.a).to eq("10")
|
154
154
|
end
|
@@ -7,30 +7,30 @@ describe Gitlab::Client do
|
|
7
7
|
@pipelines = Gitlab.pipelines(3)
|
8
8
|
end
|
9
9
|
|
10
|
-
it "
|
10
|
+
it "gets the correct resource" do
|
11
11
|
expect(a_get("/projects/3/pipelines")).to have_been_made
|
12
12
|
end
|
13
13
|
|
14
|
-
it "
|
14
|
+
it "returns a paginated response of project's pipelines" do
|
15
15
|
expect(@pipelines).to be_a Gitlab::PaginatedResponse
|
16
16
|
end
|
17
17
|
end
|
18
|
-
|
18
|
+
|
19
19
|
describe ".pipeline" do
|
20
20
|
before do
|
21
21
|
stub_get("/projects/3/pipelines/46", "pipeline")
|
22
22
|
@pipeline = Gitlab.pipeline(3, 46)
|
23
23
|
end
|
24
|
-
|
25
|
-
it "
|
24
|
+
|
25
|
+
it "gets the correct resource" do
|
26
26
|
expect(a_get("/projects/3/pipelines/46")).to have_been_made
|
27
27
|
end
|
28
28
|
|
29
|
-
it "
|
29
|
+
it "returns a single pipeline" do
|
30
30
|
expect(@pipeline).to be_a Gitlab::ObjectifiedHash
|
31
31
|
end
|
32
|
-
|
33
|
-
it "
|
32
|
+
|
33
|
+
it "returns information about a pipeline" do
|
34
34
|
expect(@pipeline.id).to eq(46)
|
35
35
|
expect(@pipeline.user.name).to eq("Administrator")
|
36
36
|
end
|
@@ -42,15 +42,15 @@ describe Gitlab::Client do
|
|
42
42
|
@pipeline_create = Gitlab.create_pipeline(3, 'master')
|
43
43
|
end
|
44
44
|
|
45
|
-
it "
|
45
|
+
it "gets the correct resource" do
|
46
46
|
expect(a_post("/projects/3/pipeline?ref=master")).to have_been_made
|
47
47
|
end
|
48
48
|
|
49
|
-
it "
|
49
|
+
it "returns a single pipeline" do
|
50
50
|
expect(@pipeline_create).to be_a Gitlab::ObjectifiedHash
|
51
51
|
end
|
52
52
|
|
53
|
-
it "
|
53
|
+
it "returns information about a pipeline" do
|
54
54
|
expect(@pipeline_create.user.name).to eq("Administrator")
|
55
55
|
end
|
56
56
|
end
|
@@ -60,35 +60,35 @@ describe Gitlab::Client do
|
|
60
60
|
stub_post("/projects/3/pipelines/46/cancel", "pipeline_cancel")
|
61
61
|
@pipeline_cancel = Gitlab.cancel_pipeline(3, 46)
|
62
62
|
end
|
63
|
-
|
64
|
-
it "
|
63
|
+
|
64
|
+
it "gets the correct resource" do
|
65
65
|
expect(a_post("/projects/3/pipelines/46/cancel")).to have_been_made
|
66
66
|
end
|
67
67
|
|
68
|
-
it "
|
68
|
+
it "returns a single pipeline" do
|
69
69
|
expect(@pipeline_cancel).to be_a Gitlab::ObjectifiedHash
|
70
70
|
end
|
71
|
-
|
72
|
-
it "
|
71
|
+
|
72
|
+
it "returns information about a pipeline" do
|
73
73
|
expect(@pipeline_cancel.user.name).to eq("Administrator")
|
74
74
|
end
|
75
75
|
end
|
76
|
-
|
76
|
+
|
77
77
|
describe ".retry_pipeline" do
|
78
78
|
before do
|
79
79
|
stub_post("/projects/3/pipelines/46/retry", "pipeline_retry")
|
80
80
|
@pipeline_retry = Gitlab.retry_pipeline(3, 46)
|
81
81
|
end
|
82
|
-
|
83
|
-
it "
|
82
|
+
|
83
|
+
it "gets the correct resource" do
|
84
84
|
expect(a_post("/projects/3/pipelines/46/retry")).to have_been_made
|
85
85
|
end
|
86
86
|
|
87
|
-
it "
|
87
|
+
it "returns a single pipeline" do
|
88
88
|
expect(@pipeline_retry).to be_a Gitlab::ObjectifiedHash
|
89
89
|
end
|
90
|
-
|
91
|
-
it "
|
90
|
+
|
91
|
+
it "returns information about a pipeline" do
|
92
92
|
expect(@pipeline_retry.user.name).to eq("Administrator")
|
93
93
|
end
|
94
94
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Gitlab::Client do
|
4
|
-
it {
|
4
|
+
it { is_expected.to respond_to :search_projects }
|
5
5
|
|
6
6
|
describe ".projects" do
|
7
7
|
before do
|
@@ -9,11 +9,11 @@ describe Gitlab::Client do
|
|
9
9
|
@projects = Gitlab.projects
|
10
10
|
end
|
11
11
|
|
12
|
-
it "
|
12
|
+
it "gets the correct resource" do
|
13
13
|
expect(a_get("/projects")).to have_been_made
|
14
14
|
end
|
15
15
|
|
16
|
-
it "
|
16
|
+
it "returns a paginated response of projects" do
|
17
17
|
expect(@projects).to be_a Gitlab::PaginatedResponse
|
18
18
|
expect(@projects.first.name).to eq("Brute")
|
19
19
|
expect(@projects.first.owner.name).to eq("John Smith")
|
@@ -26,11 +26,11 @@ describe Gitlab::Client do
|
|
26
26
|
@project_search = Gitlab.project_search("Gitlab")
|
27
27
|
end
|
28
28
|
|
29
|
-
it "
|
29
|
+
it "gets the correct resource" do
|
30
30
|
expect(a_get("/projects?search=Gitlab")).to have_been_made
|
31
31
|
end
|
32
32
|
|
33
|
-
it "
|
33
|
+
it "returns a paginated response of projects found" do
|
34
34
|
expect(@project_search).to be_a Gitlab::PaginatedResponse
|
35
35
|
expect(@project_search.first.name).to eq("Gitlab")
|
36
36
|
expect(@project_search.first.owner.name).to eq("John Smith")
|
@@ -43,11 +43,11 @@ describe Gitlab::Client do
|
|
43
43
|
@project = Gitlab.project(3)
|
44
44
|
end
|
45
45
|
|
46
|
-
it "
|
46
|
+
it "gets the correct resource" do
|
47
47
|
expect(a_get("/projects/3")).to have_been_made
|
48
48
|
end
|
49
49
|
|
50
|
-
it "
|
50
|
+
it "returns information about a project" do
|
51
51
|
expect(@project.name).to eq("Gitlab")
|
52
52
|
expect(@project.owner.name).to eq("John Smith")
|
53
53
|
end
|
@@ -59,16 +59,16 @@ describe Gitlab::Client do
|
|
59
59
|
@events = Gitlab.project_events(2)
|
60
60
|
end
|
61
61
|
|
62
|
-
it "
|
62
|
+
it "gets the correct resource" do
|
63
63
|
expect(a_get("/projects/2/events")).to have_been_made
|
64
64
|
end
|
65
65
|
|
66
|
-
it "
|
66
|
+
it "returns a paginated response of events" do
|
67
67
|
expect(@events).to be_a Gitlab::PaginatedResponse
|
68
68
|
expect(@events.size).to eq(2)
|
69
69
|
end
|
70
70
|
|
71
|
-
it "
|
71
|
+
it "returns the action name of the event" do
|
72
72
|
expect(@events.first.action_name).to eq("opened")
|
73
73
|
end
|
74
74
|
end
|
@@ -79,11 +79,11 @@ describe Gitlab::Client do
|
|
79
79
|
@project = Gitlab.create_project('Gitlab')
|
80
80
|
end
|
81
81
|
|
82
|
-
it "
|
82
|
+
it "gets the correct resource" do
|
83
83
|
expect(a_post("/projects")).to have_been_made
|
84
84
|
end
|
85
85
|
|
86
|
-
it "
|
86
|
+
it "returns information about a created project" do
|
87
87
|
expect(@project.name).to eq("Gitlab")
|
88
88
|
expect(@project.owner.name).to eq("John Smith")
|
89
89
|
end
|
@@ -97,7 +97,7 @@ describe Gitlab::Client do
|
|
97
97
|
@project = Gitlab.create_project('Brute', user_id: @owner.id)
|
98
98
|
end
|
99
99
|
|
100
|
-
it "
|
100
|
+
it "returns information about a created project" do
|
101
101
|
expect(@project.name).to eq("Brute")
|
102
102
|
expect(@project.owner.name).to eq("John Owner")
|
103
103
|
end
|
@@ -109,11 +109,11 @@ describe Gitlab::Client do
|
|
109
109
|
@project = Gitlab.delete_project('Gitlab')
|
110
110
|
end
|
111
111
|
|
112
|
-
it "
|
112
|
+
it "gets the correct resource" do
|
113
113
|
expect(a_delete("/projects/Gitlab")).to have_been_made
|
114
114
|
end
|
115
115
|
|
116
|
-
it "
|
116
|
+
it "returns information about a deleted project" do
|
117
117
|
expect(@project.name).to eq("Gitlab")
|
118
118
|
expect(@project.owner.name).to eq("John Smith")
|
119
119
|
end
|
@@ -126,11 +126,11 @@ describe Gitlab::Client do
|
|
126
126
|
@project = Gitlab.create_fork(3)
|
127
127
|
end
|
128
128
|
|
129
|
-
it "
|
129
|
+
it "posts to the correct resource" do
|
130
130
|
expect(a_post("/projects/3/fork")).to have_been_made
|
131
131
|
end
|
132
132
|
|
133
|
-
it "
|
133
|
+
it "returns information about the forked project" do
|
134
134
|
expect(@project.forked_from_project.id).to eq(3)
|
135
135
|
expect(@project.id).to eq(20)
|
136
136
|
end
|
@@ -143,11 +143,11 @@ describe Gitlab::Client do
|
|
143
143
|
@project = Gitlab.create_fork(3, sudo: @sudoed_username)
|
144
144
|
end
|
145
145
|
|
146
|
-
it "
|
146
|
+
it "posts to the correct resource" do
|
147
147
|
expect(a_post("/projects/3/fork")).to have_been_made
|
148
148
|
end
|
149
149
|
|
150
|
-
it "
|
150
|
+
it "returns information about the forked project" do
|
151
151
|
expect(@project.forked_from_project.id).to eq(3)
|
152
152
|
expect(@project.id).to eq(20)
|
153
153
|
expect(@project.owner.username).to eq(@sudoed_username)
|
@@ -161,11 +161,11 @@ describe Gitlab::Client do
|
|
161
161
|
@team_members = Gitlab.team_members(3)
|
162
162
|
end
|
163
163
|
|
164
|
-
it "
|
164
|
+
it "gets the correct resource" do
|
165
165
|
expect(a_get("/projects/3/members")).to have_been_made
|
166
166
|
end
|
167
167
|
|
168
|
-
it "
|
168
|
+
it "returns a paginated response of team members" do
|
169
169
|
expect(@team_members).to be_a Gitlab::PaginatedResponse
|
170
170
|
expect(@team_members.first.name).to eq("John Smith")
|
171
171
|
end
|
@@ -177,11 +177,11 @@ describe Gitlab::Client do
|
|
177
177
|
@team_member = Gitlab.team_member(3, 1)
|
178
178
|
end
|
179
179
|
|
180
|
-
it "
|
180
|
+
it "gets the correct resource" do
|
181
181
|
expect(a_get("/projects/3/members/1")).to have_been_made
|
182
182
|
end
|
183
183
|
|
184
|
-
it "
|
184
|
+
it "returns information about a team member" do
|
185
185
|
expect(@team_member.name).to eq("John Smith")
|
186
186
|
end
|
187
187
|
end
|
@@ -192,12 +192,12 @@ describe Gitlab::Client do
|
|
192
192
|
@team_member = Gitlab.add_team_member(3, 1, 40)
|
193
193
|
end
|
194
194
|
|
195
|
-
it "
|
195
|
+
it "gets the correct resource" do
|
196
196
|
expect(a_post("/projects/3/members").
|
197
197
|
with(body: { user_id: '1', access_level: '40' })).to have_been_made
|
198
198
|
end
|
199
199
|
|
200
|
-
it "
|
200
|
+
it "returns information about an added team member" do
|
201
201
|
expect(@team_member.name).to eq("John Smith")
|
202
202
|
end
|
203
203
|
end
|
@@ -208,12 +208,12 @@ describe Gitlab::Client do
|
|
208
208
|
@team_member = Gitlab.edit_team_member(3, 1, 40)
|
209
209
|
end
|
210
210
|
|
211
|
-
it "
|
211
|
+
it "gets the correct resource" do
|
212
212
|
expect(a_put("/projects/3/members/1").
|
213
213
|
with(body: { access_level: '40' })).to have_been_made
|
214
214
|
end
|
215
215
|
|
216
|
-
it "
|
216
|
+
it "returns information about an edited team member" do
|
217
217
|
expect(@team_member.name).to eq("John Smith")
|
218
218
|
end
|
219
219
|
end
|
@@ -224,11 +224,11 @@ describe Gitlab::Client do
|
|
224
224
|
@team_member = Gitlab.remove_team_member(3, 1)
|
225
225
|
end
|
226
226
|
|
227
|
-
it "
|
227
|
+
it "gets the correct resource" do
|
228
228
|
expect(a_delete("/projects/3/members/1")).to have_been_made
|
229
229
|
end
|
230
230
|
|
231
|
-
it "
|
231
|
+
it "returns information about a removed team member" do
|
232
232
|
expect(@team_member.name).to eq("John Smith")
|
233
233
|
end
|
234
234
|
end
|
@@ -239,11 +239,11 @@ describe Gitlab::Client do
|
|
239
239
|
@hooks = Gitlab.project_hooks(1)
|
240
240
|
end
|
241
241
|
|
242
|
-
it "
|
242
|
+
it "gets the correct resource" do
|
243
243
|
expect(a_get("/projects/1/hooks")).to have_been_made
|
244
244
|
end
|
245
245
|
|
246
|
-
it "
|
246
|
+
it "returns a paginated response of hooks" do
|
247
247
|
expect(@hooks).to be_a Gitlab::PaginatedResponse
|
248
248
|
expect(@hooks.first.url).to eq("https://api.example.net/v1/webhooks/ci")
|
249
249
|
end
|
@@ -255,11 +255,11 @@ describe Gitlab::Client do
|
|
255
255
|
@hook = Gitlab.project_hook(1, 1)
|
256
256
|
end
|
257
257
|
|
258
|
-
it "
|
258
|
+
it "gets the correct resource" do
|
259
259
|
expect(a_get("/projects/1/hooks/1")).to have_been_made
|
260
260
|
end
|
261
261
|
|
262
|
-
it "
|
262
|
+
it "returns information about a hook" do
|
263
263
|
expect(@hook.url).to eq("https://api.example.net/v1/webhooks/ci")
|
264
264
|
end
|
265
265
|
end
|
@@ -271,12 +271,12 @@ describe Gitlab::Client do
|
|
271
271
|
@hook = Gitlab.add_project_hook(1, "https://api.example.net/v1/webhooks/ci")
|
272
272
|
end
|
273
273
|
|
274
|
-
it "
|
274
|
+
it "gets the correct resource" do
|
275
275
|
body = { url: "https://api.example.net/v1/webhooks/ci" }
|
276
276
|
expect(a_post("/projects/1/hooks").with(body: body)).to have_been_made
|
277
277
|
end
|
278
278
|
|
279
|
-
it "
|
279
|
+
it "returns information about an added hook" do
|
280
280
|
expect(@hook.url).to eq("https://api.example.net/v1/webhooks/ci")
|
281
281
|
end
|
282
282
|
end
|
@@ -287,12 +287,12 @@ describe Gitlab::Client do
|
|
287
287
|
@hook = Gitlab.add_project_hook(1, "https://api.example.net/v1/webhooks/ci", push_events: true, merge_requests_events: true)
|
288
288
|
end
|
289
289
|
|
290
|
-
it "
|
290
|
+
it "gets the correct resource" do
|
291
291
|
body = { url: "https://api.example.net/v1/webhooks/ci", push_events: "true", merge_requests_events: "true" }
|
292
292
|
expect(a_post("/projects/1/hooks").with(body: body)).to have_been_made
|
293
293
|
end
|
294
294
|
|
295
|
-
it "
|
295
|
+
it "returns information about an added hook" do
|
296
296
|
expect(@hook.url).to eq("https://api.example.net/v1/webhooks/ci")
|
297
297
|
end
|
298
298
|
end
|
@@ -304,12 +304,12 @@ describe Gitlab::Client do
|
|
304
304
|
@hook = Gitlab.edit_project_hook(1, 1, "https://api.example.net/v1/webhooks/ci")
|
305
305
|
end
|
306
306
|
|
307
|
-
it "
|
307
|
+
it "gets the correct resource" do
|
308
308
|
body = { url: "https://api.example.net/v1/webhooks/ci" }
|
309
309
|
expect(a_put("/projects/1/hooks/1").with(body: body)).to have_been_made
|
310
310
|
end
|
311
311
|
|
312
|
-
it "
|
312
|
+
it "returns information about an edited hook" do
|
313
313
|
expect(@hook.url).to eq("https://api.example.net/v1/webhooks/ci")
|
314
314
|
end
|
315
315
|
end
|
@@ -321,11 +321,11 @@ describe Gitlab::Client do
|
|
321
321
|
@edited_project = Gitlab.edit_project(3, name: "Gitlab-edit")
|
322
322
|
end
|
323
323
|
|
324
|
-
it "
|
324
|
+
it "gets the correct resource" do
|
325
325
|
expect(a_put("/projects/3").with(body: { name: "Gitlab-edit" })).to have_been_made
|
326
326
|
end
|
327
327
|
|
328
|
-
it "
|
328
|
+
it "returns information about an edited project" do
|
329
329
|
expect(@edited_project.name).to eq("Gitlab-edit")
|
330
330
|
end
|
331
331
|
end
|
@@ -348,11 +348,11 @@ describe Gitlab::Client do
|
|
348
348
|
@hook = Gitlab.delete_project_hook(1, 1)
|
349
349
|
end
|
350
350
|
|
351
|
-
it "
|
351
|
+
it "gets the correct resource" do
|
352
352
|
expect(a_delete("/projects/1/hooks/1")).to have_been_made
|
353
353
|
end
|
354
354
|
|
355
|
-
it "
|
355
|
+
it "returns false" do
|
356
356
|
expect(@hook).to be(false)
|
357
357
|
end
|
358
358
|
end
|
@@ -363,11 +363,11 @@ describe Gitlab::Client do
|
|
363
363
|
@hook = Gitlab.delete_project_hook(1, 1)
|
364
364
|
end
|
365
365
|
|
366
|
-
it "
|
366
|
+
it "gets the correct resource" do
|
367
367
|
expect(a_delete("/projects/1/hooks/1")).to have_been_made
|
368
368
|
end
|
369
369
|
|
370
|
-
it "
|
370
|
+
it "returns information about a deleted hook" do
|
371
371
|
expect(@hook.url).to eq("https://api.example.net/v1/webhooks/ci")
|
372
372
|
end
|
373
373
|
end
|
@@ -379,11 +379,11 @@ describe Gitlab::Client do
|
|
379
379
|
@push_rule = Gitlab.push_rule(1)
|
380
380
|
end
|
381
381
|
|
382
|
-
it "
|
382
|
+
it "gets the correct resource" do
|
383
383
|
expect(a_get("/projects/1/push_rule")).to have_been_made
|
384
384
|
end
|
385
385
|
|
386
|
-
it "
|
386
|
+
it "returns information about a push rule" do
|
387
387
|
expect(@push_rule.commit_message_regex).to eq("\\b[A-Z]{3}-[0-9]+\\b")
|
388
388
|
end
|
389
389
|
end
|
@@ -394,11 +394,11 @@ describe Gitlab::Client do
|
|
394
394
|
@push_rule = Gitlab.add_push_rule(1, { deny_delete_tag: false, commit_message_regex: "\\b[A-Z]{3}-[0-9]+\\b" })
|
395
395
|
end
|
396
396
|
|
397
|
-
it "
|
397
|
+
it "gets the correct resource" do
|
398
398
|
expect(a_post("/projects/1/push_rule")).to have_been_made
|
399
399
|
end
|
400
400
|
|
401
|
-
it "
|
401
|
+
it "returns information about an added push rule" do
|
402
402
|
expect(@push_rule.commit_message_regex).to eq("\\b[A-Z]{3}-[0-9]+\\b")
|
403
403
|
end
|
404
404
|
end
|
@@ -409,11 +409,11 @@ describe Gitlab::Client do
|
|
409
409
|
@push_rule = Gitlab.edit_push_rule(1, { deny_delete_tag: false, commit_message_regex: "\\b[A-Z]{3}-[0-9]+\\b" })
|
410
410
|
end
|
411
411
|
|
412
|
-
it "
|
412
|
+
it "gets the correct resource" do
|
413
413
|
expect(a_put("/projects/1/push_rule")).to have_been_made
|
414
414
|
end
|
415
415
|
|
416
|
-
it "
|
416
|
+
it "returns information about an edited push rule" do
|
417
417
|
expect(@push_rule.commit_message_regex).to eq("\\b[A-Z]{3}-[0-9]+\\b")
|
418
418
|
end
|
419
419
|
end
|
@@ -427,11 +427,11 @@ describe Gitlab::Client do
|
|
427
427
|
@push_rule = Gitlab.delete_push_rule(1)
|
428
428
|
end
|
429
429
|
|
430
|
-
it "
|
430
|
+
it "gets the correct resource" do
|
431
431
|
expect(a_delete("/projects/1/push_rule")).to have_been_made
|
432
432
|
end
|
433
433
|
|
434
|
-
it "
|
434
|
+
it "returns false" do
|
435
435
|
expect(@push_rule).to be(false)
|
436
436
|
end
|
437
437
|
end
|
@@ -442,11 +442,11 @@ describe Gitlab::Client do
|
|
442
442
|
@push_rule = Gitlab.delete_push_rule(1)
|
443
443
|
end
|
444
444
|
|
445
|
-
it "
|
445
|
+
it "gets the correct resource" do
|
446
446
|
expect(a_delete("/projects/1/push_rule")).to have_been_made
|
447
447
|
end
|
448
448
|
|
449
|
-
it "
|
449
|
+
it "returns information about a deleted push rule" do
|
450
450
|
expect(@push_rule.commit_message_regex).to eq("\\b[A-Z]{3}-[0-9]+\\b")
|
451
451
|
end
|
452
452
|
end
|
@@ -458,11 +458,11 @@ describe Gitlab::Client do
|
|
458
458
|
@forked_project_link = Gitlab.make_forked_from(42, 24)
|
459
459
|
end
|
460
460
|
|
461
|
-
it "
|
461
|
+
it "gets the correct resource" do
|
462
462
|
expect(a_post("/projects/42/fork/24")).to have_been_made
|
463
463
|
end
|
464
464
|
|
465
|
-
it "
|
465
|
+
it "returns information about a forked project" do
|
466
466
|
expect(@forked_project_link.forked_from_project_id).to eq(24)
|
467
467
|
expect(@forked_project_link.forked_to_project_id).to eq(42)
|
468
468
|
end
|
@@ -474,11 +474,11 @@ describe Gitlab::Client do
|
|
474
474
|
@forked_project_link = Gitlab.remove_forked(42)
|
475
475
|
end
|
476
476
|
|
477
|
-
it "
|
477
|
+
it "gets the correct resource" do
|
478
478
|
expect(a_delete("/projects/42/fork")).to have_been_made
|
479
479
|
end
|
480
480
|
|
481
|
-
it "
|
481
|
+
it "returns information about an unforked project" do
|
482
482
|
expect(@forked_project_link.forked_to_project_id).to eq(42)
|
483
483
|
end
|
484
484
|
end
|
@@ -489,11 +489,11 @@ describe Gitlab::Client do
|
|
489
489
|
@deploy_keys = Gitlab.deploy_keys(42)
|
490
490
|
end
|
491
491
|
|
492
|
-
it "
|
492
|
+
it "gets the correct resource" do
|
493
493
|
expect(a_get("/projects/42/deploy_keys")).to have_been_made
|
494
494
|
end
|
495
495
|
|
496
|
-
it "
|
496
|
+
it "returns project deploy keys" do
|
497
497
|
expect(@deploy_keys).to be_a Gitlab::PaginatedResponse
|
498
498
|
expect(@deploy_keys.first.id).to eq 2
|
499
499
|
expect(@deploy_keys.first.title).to eq "Key Title"
|
@@ -507,11 +507,11 @@ describe Gitlab::Client do
|
|
507
507
|
@deploy_key = Gitlab.deploy_key(42, 2)
|
508
508
|
end
|
509
509
|
|
510
|
-
it "
|
510
|
+
it "gets the correct resource" do
|
511
511
|
expect(a_get("/projects/42/deploy_keys/2")).to have_been_made
|
512
512
|
end
|
513
513
|
|
514
|
-
it "
|
514
|
+
it "returns project deploy key" do
|
515
515
|
expect(@deploy_key.id).to eq 2
|
516
516
|
expect(@deploy_key.title).to eq "Key Title"
|
517
517
|
expect(@deploy_key.key).to match(/ssh-rsa/)
|
@@ -524,11 +524,11 @@ describe Gitlab::Client do
|
|
524
524
|
@deploy_key = Gitlab.delete_deploy_key(42, 2)
|
525
525
|
end
|
526
526
|
|
527
|
-
it "
|
527
|
+
it "gets the correct resource" do
|
528
528
|
expect(a_delete("/projects/42/deploy_keys/2")).to have_been_made
|
529
529
|
end
|
530
530
|
|
531
|
-
it "
|
531
|
+
it "returns information about a deleted key" do
|
532
532
|
expect(@deploy_key.id).to eq(2)
|
533
533
|
end
|
534
534
|
end
|
@@ -539,12 +539,12 @@ describe Gitlab::Client do
|
|
539
539
|
@deploy_key = Gitlab.enable_deploy_key(42, 2)
|
540
540
|
end
|
541
541
|
|
542
|
-
it "
|
542
|
+
it "gets the correct resource" do
|
543
543
|
expect(a_post("/projects/42/deploy_keys/2/enable").
|
544
544
|
with(body: { id: '42', key_id: '2' })).to have_been_made
|
545
545
|
end
|
546
546
|
|
547
|
-
it "
|
547
|
+
it "returns information about an enabled key" do
|
548
548
|
expect(@deploy_key.id).to eq(2)
|
549
549
|
end
|
550
550
|
end
|
@@ -555,12 +555,12 @@ describe Gitlab::Client do
|
|
555
555
|
@deploy_key = Gitlab.disable_deploy_key(42, 2)
|
556
556
|
end
|
557
557
|
|
558
|
-
it "
|
558
|
+
it "gets the correct resource" do
|
559
559
|
expect(a_post("/projects/42/deploy_keys/2/disable").
|
560
560
|
with(body: { id: '42', key_id: '2' })).to have_been_made
|
561
561
|
end
|
562
562
|
|
563
|
-
it "
|
563
|
+
it "returns information about a disabled key" do
|
564
564
|
expect(@deploy_key.id).to eq(2)
|
565
565
|
end
|
566
566
|
end
|
@@ -571,12 +571,12 @@ describe Gitlab::Client do
|
|
571
571
|
@group = Gitlab.share_project_with_group(3, 10, 40)
|
572
572
|
end
|
573
573
|
|
574
|
-
it "
|
574
|
+
it "gets the correct resource" do
|
575
575
|
expect(a_post("/projects/3/share").
|
576
576
|
with(body: { group_id: '10', group_access: '40' })).to have_been_made
|
577
577
|
end
|
578
578
|
|
579
|
-
it "
|
579
|
+
it "returns information about an added group" do
|
580
580
|
expect(@group.id).to eq(10)
|
581
581
|
end
|
582
582
|
end
|
@@ -587,11 +587,11 @@ describe Gitlab::Client do
|
|
587
587
|
@starred_project = Gitlab.star_project(3)
|
588
588
|
end
|
589
589
|
|
590
|
-
it "
|
590
|
+
it "gets the correct resource" do
|
591
591
|
expect(a_post("/projects/3/star")).to have_been_made
|
592
592
|
end
|
593
593
|
|
594
|
-
it "
|
594
|
+
it "returns information about the starred project" do
|
595
595
|
expect(@starred_project.id).to eq(3)
|
596
596
|
end
|
597
597
|
end
|
@@ -602,11 +602,11 @@ describe Gitlab::Client do
|
|
602
602
|
@unstarred_project = Gitlab.unstar_project(3)
|
603
603
|
end
|
604
604
|
|
605
|
-
it "
|
605
|
+
it "gets the correct resource" do
|
606
606
|
expect(a_delete("/projects/3/star")).to have_been_made
|
607
607
|
end
|
608
608
|
|
609
|
-
it "
|
609
|
+
it "returns information about the unstarred project" do
|
610
610
|
expect(@unstarred_project.id).to eq(3)
|
611
611
|
end
|
612
612
|
end
|