gitlab-akerl 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +20 -0
- data/.prospectus +11 -0
- data/.travis.yml +8 -0
- data/CHANGELOG.md +229 -0
- data/CONTRIBUTING.md +195 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +24 -0
- data/README.md +192 -0
- data/Rakefile +9 -0
- data/bin/console +10 -0
- data/bin/setup +6 -0
- data/exe/gitlab +7 -0
- data/gitlab-akerl.gemspec +31 -0
- data/lib/gitlab.rb +45 -0
- data/lib/gitlab/api.rb +19 -0
- data/lib/gitlab/cli.rb +89 -0
- data/lib/gitlab/cli_helpers.rb +241 -0
- data/lib/gitlab/client.rb +48 -0
- data/lib/gitlab/client/branches.rb +91 -0
- data/lib/gitlab/client/build_triggers.rb +51 -0
- data/lib/gitlab/client/build_variables.rb +66 -0
- data/lib/gitlab/client/builds.rb +106 -0
- data/lib/gitlab/client/commits.rb +121 -0
- data/lib/gitlab/client/groups.rb +144 -0
- data/lib/gitlab/client/issues.rb +113 -0
- data/lib/gitlab/client/labels.rb +57 -0
- data/lib/gitlab/client/merge_requests.rb +168 -0
- data/lib/gitlab/client/milestones.rb +78 -0
- data/lib/gitlab/client/namespaces.rb +20 -0
- data/lib/gitlab/client/notes.rb +161 -0
- data/lib/gitlab/client/pipelines.rb +68 -0
- data/lib/gitlab/client/projects.rb +471 -0
- data/lib/gitlab/client/repositories.rb +78 -0
- data/lib/gitlab/client/repository_files.rb +88 -0
- data/lib/gitlab/client/runners.rb +115 -0
- data/lib/gitlab/client/services.rb +50 -0
- data/lib/gitlab/client/snippets.rb +91 -0
- data/lib/gitlab/client/system_hooks.rb +59 -0
- data/lib/gitlab/client/tags.rb +96 -0
- data/lib/gitlab/client/users.rb +250 -0
- data/lib/gitlab/configuration.rb +55 -0
- data/lib/gitlab/error.rb +85 -0
- data/lib/gitlab/file_response.rb +46 -0
- data/lib/gitlab/help.rb +95 -0
- data/lib/gitlab/objectified_hash.rb +34 -0
- data/lib/gitlab/page_links.rb +33 -0
- data/lib/gitlab/paginated_response.rb +97 -0
- data/lib/gitlab/request.rb +117 -0
- data/lib/gitlab/shell.rb +84 -0
- data/lib/gitlab/shell_history.rb +59 -0
- data/lib/gitlab/version.rb +3 -0
- data/spec/fixtures/branch.json +1 -0
- data/spec/fixtures/branch_delete.json +3 -0
- data/spec/fixtures/branches.json +1 -0
- data/spec/fixtures/build.json +38 -0
- data/spec/fixtures/build_artifacts.json +0 -0
- data/spec/fixtures/build_cancel.json +24 -0
- data/spec/fixtures/build_erase.json +24 -0
- data/spec/fixtures/build_retry.json +24 -0
- data/spec/fixtures/builds.json +78 -0
- data/spec/fixtures/builds_commits.json +64 -0
- data/spec/fixtures/compare_merge_request_diff.json +31 -0
- data/spec/fixtures/error_already_exists.json +1 -0
- data/spec/fixtures/error_project_not_found.json +1 -0
- data/spec/fixtures/get_repository_file.json +1 -0
- data/spec/fixtures/git_hook.json +1 -0
- data/spec/fixtures/group.json +60 -0
- data/spec/fixtures/group_create.json +1 -0
- data/spec/fixtures/group_create_with_description.json +1 -0
- data/spec/fixtures/group_delete.json +1 -0
- data/spec/fixtures/group_member.json +1 -0
- data/spec/fixtures/group_member_delete.json +1 -0
- data/spec/fixtures/group_member_edit.json +1 -0
- data/spec/fixtures/group_members.json +1 -0
- data/spec/fixtures/group_projects.json +44 -0
- data/spec/fixtures/group_search.json +2 -0
- data/spec/fixtures/groups.json +2 -0
- data/spec/fixtures/issue.json +1 -0
- data/spec/fixtures/issues.json +1 -0
- data/spec/fixtures/key.json +1 -0
- data/spec/fixtures/keys.json +1 -0
- data/spec/fixtures/label.json +1 -0
- data/spec/fixtures/labels.json +1 -0
- data/spec/fixtures/merge_request.json +1 -0
- data/spec/fixtures/merge_request_changes.json +1 -0
- data/spec/fixtures/merge_request_comment.json +1 -0
- data/spec/fixtures/merge_request_comments.json +1 -0
- data/spec/fixtures/merge_request_commits.json +1 -0
- data/spec/fixtures/merge_requests.json +1 -0
- data/spec/fixtures/milestone.json +1 -0
- data/spec/fixtures/milestone_issues.json +1 -0
- data/spec/fixtures/milestones.json +1 -0
- data/spec/fixtures/namespaces.json +1 -0
- data/spec/fixtures/note.json +1 -0
- data/spec/fixtures/notes.json +1 -0
- data/spec/fixtures/pipeline.json +23 -0
- data/spec/fixtures/pipeline_cancel.json +23 -0
- data/spec/fixtures/pipeline_create.json +23 -0
- data/spec/fixtures/pipeline_retry.json +23 -0
- data/spec/fixtures/pipelines.json +48 -0
- data/spec/fixtures/project.json +1 -0
- data/spec/fixtures/project_commit.json +13 -0
- data/spec/fixtures/project_commit_comment.json +1 -0
- data/spec/fixtures/project_commit_comments.json +1 -0
- data/spec/fixtures/project_commit_diff.json +10 -0
- data/spec/fixtures/project_commit_status.json +42 -0
- data/spec/fixtures/project_commits.json +1 -0
- data/spec/fixtures/project_edit.json +21 -0
- data/spec/fixtures/project_events.json +1 -0
- data/spec/fixtures/project_for_user.json +1 -0
- data/spec/fixtures/project_fork.json +50 -0
- data/spec/fixtures/project_fork_link.json +1 -0
- data/spec/fixtures/project_forked_for_user.json +50 -0
- data/spec/fixtures/project_hook.json +1 -0
- data/spec/fixtures/project_hooks.json +1 -0
- data/spec/fixtures/project_issues.json +1 -0
- data/spec/fixtures/project_key.json +6 -0
- data/spec/fixtures/project_keys.json +6 -0
- data/spec/fixtures/project_runner_enable.json +7 -0
- data/spec/fixtures/project_runners.json +16 -0
- data/spec/fixtures/project_search.json +1 -0
- data/spec/fixtures/project_star.json +44 -0
- data/spec/fixtures/project_tag_annotated.json +1 -0
- data/spec/fixtures/project_tag_lightweight.json +1 -0
- data/spec/fixtures/project_tags.json +1 -0
- data/spec/fixtures/project_unstar.json +44 -0
- data/spec/fixtures/project_update_commit_status.json +20 -0
- data/spec/fixtures/projects.json +1 -0
- data/spec/fixtures/raw_file.json +2 -0
- data/spec/fixtures/release_create.json +1 -0
- data/spec/fixtures/release_update.json +1 -0
- data/spec/fixtures/repository_file.json +1 -0
- data/spec/fixtures/runner.json +26 -0
- data/spec/fixtures/runner_delete.json +7 -0
- data/spec/fixtures/runner_edit.json +26 -0
- data/spec/fixtures/runners.json +16 -0
- data/spec/fixtures/runners_all.json +30 -0
- data/spec/fixtures/service.json +1 -0
- data/spec/fixtures/session.json +1 -0
- data/spec/fixtures/shell_history.json +2 -0
- data/spec/fixtures/snippet.json +1 -0
- data/spec/fixtures/snippet_content.json +3 -0
- data/spec/fixtures/snippets.json +1 -0
- data/spec/fixtures/system_hook.json +1 -0
- data/spec/fixtures/system_hooks.json +1 -0
- data/spec/fixtures/tag.json +1 -0
- data/spec/fixtures/tag_create.json +1 -0
- data/spec/fixtures/tag_create_with_description.json +1 -0
- data/spec/fixtures/tag_delete.json +1 -0
- data/spec/fixtures/tags.json +1 -0
- data/spec/fixtures/team_member.json +1 -0
- data/spec/fixtures/team_members.json +1 -0
- data/spec/fixtures/tree.json +1 -0
- data/spec/fixtures/trigger.json +7 -0
- data/spec/fixtures/triggers.json +16 -0
- data/spec/fixtures/user.json +1 -0
- data/spec/fixtures/user_block_unblock.json +1 -0
- data/spec/fixtures/user_email.json +1 -0
- data/spec/fixtures/user_emails.json +1 -0
- data/spec/fixtures/user_search.json +1 -0
- data/spec/fixtures/users.json +1 -0
- data/spec/fixtures/variable.json +4 -0
- data/spec/fixtures/variables.json +10 -0
- data/spec/gitlab/cli_helpers_spec.rb +57 -0
- data/spec/gitlab/cli_spec.rb +110 -0
- data/spec/gitlab/client/branches_spec.rb +99 -0
- data/spec/gitlab/client/build_triggers_spec.rb +67 -0
- data/spec/gitlab/client/build_variables_spec.rb +86 -0
- data/spec/gitlab/client/builds_spec.rb +148 -0
- data/spec/gitlab/client/client_spec.rb +11 -0
- data/spec/gitlab/client/commits_spec.rb +137 -0
- data/spec/gitlab/client/groups_spec.rb +197 -0
- data/spec/gitlab/client/issues_spec.rb +138 -0
- data/spec/gitlab/client/labels_spec.rb +68 -0
- data/spec/gitlab/client/merge_requests_spec.rb +177 -0
- data/spec/gitlab/client/milestones_spec.rb +82 -0
- data/spec/gitlab/client/namespaces_spec.rb +22 -0
- data/spec/gitlab/client/notes_spec.rb +205 -0
- data/spec/gitlab/client/pipelines_spec.rb +95 -0
- data/spec/gitlab/client/projects_spec.rb +603 -0
- data/spec/gitlab/client/repositories_spec.rb +109 -0
- data/spec/gitlab/client/repository_files_spec.rb +62 -0
- data/spec/gitlab/client/runners_spec.rb +185 -0
- data/spec/gitlab/client/services_spec.rb +55 -0
- data/spec/gitlab/client/snippets_spec.rb +100 -0
- data/spec/gitlab/client/system_hooks_spec.rb +69 -0
- data/spec/gitlab/client/tags_spec.rb +109 -0
- data/spec/gitlab/client/users_spec.rb +418 -0
- data/spec/gitlab/error_spec.rb +45 -0
- data/spec/gitlab/file_response_spec.rb +33 -0
- data/spec/gitlab/help_spec.rb +46 -0
- data/spec/gitlab/objectified_hash_spec.rb +48 -0
- data/spec/gitlab/page_links_spec.rb +16 -0
- data/spec/gitlab/paginated_response_spec.rb +60 -0
- data/spec/gitlab/request_spec.rb +73 -0
- data/spec/gitlab/shell_history_spec.rb +53 -0
- data/spec/gitlab/shell_spec.rb +80 -0
- data/spec/gitlab_spec.rb +97 -0
- data/spec/spec_helper.rb +74 -0
- metadata +476 -0
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Gitlab::Client do
|
|
4
|
+
describe '#inspect' do
|
|
5
|
+
it 'masks tokens on inspect' do
|
|
6
|
+
client = described_class.new(private_token: 'ui3gIYf4MMzTx-Oh5cEBx')
|
|
7
|
+
inspected = client.inspect
|
|
8
|
+
expect(inspected).to include('****************cEBx')
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
end
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Gitlab::Client do
|
|
4
|
+
it { should respond_to :repo_commits }
|
|
5
|
+
it { should respond_to :repo_commit }
|
|
6
|
+
it { should respond_to :repo_commit_diff }
|
|
7
|
+
it { should respond_to :repo_commit_comments }
|
|
8
|
+
it { should respond_to :repo_create_commit_comment }
|
|
9
|
+
it { should respond_to :repo_commit_status }
|
|
10
|
+
it { should respond_to :repo_update_commit_status }
|
|
11
|
+
|
|
12
|
+
describe ".commits" do
|
|
13
|
+
before do
|
|
14
|
+
stub_get("/projects/3/repository/commits", "project_commits").
|
|
15
|
+
with(query: { ref_name: "api" })
|
|
16
|
+
@commits = Gitlab.commits(3, ref_name: "api")
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
it "should get the correct resource" do
|
|
20
|
+
expect(a_get("/projects/3/repository/commits").
|
|
21
|
+
with(query: { ref_name: "api" })).to have_been_made
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
it "should return a paginated response of repository commits" do
|
|
25
|
+
expect(@commits).to be_a Gitlab::PaginatedResponse
|
|
26
|
+
expect(@commits.first.id).to eq("f7dd067490fe57505f7226c3b54d3127d2f7fd46")
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
describe ".commit" do
|
|
31
|
+
before do
|
|
32
|
+
stub_get("/projects/3/repository/commits/6104942438c14ec7bd21c6cd5bd995272b3faff6", "project_commit")
|
|
33
|
+
@commit = Gitlab.commit(3, '6104942438c14ec7bd21c6cd5bd995272b3faff6')
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
it "should get the correct resource" do
|
|
37
|
+
expect(a_get("/projects/3/repository/commits/6104942438c14ec7bd21c6cd5bd995272b3faff6")).
|
|
38
|
+
to have_been_made
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
it "should return a repository commit" do
|
|
42
|
+
expect(@commit.id).to eq("6104942438c14ec7bd21c6cd5bd995272b3faff6")
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
describe ".commit_diff" do
|
|
47
|
+
before do
|
|
48
|
+
stub_get("/projects/3/repository/commits/6104942438c14ec7bd21c6cd5bd995272b3faff6/diff", "project_commit_diff")
|
|
49
|
+
@diff = Gitlab.commit_diff(3, '6104942438c14ec7bd21c6cd5bd995272b3faff6')
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
it "should get the correct resource" do
|
|
53
|
+
expect(a_get("/projects/3/repository/commits/6104942438c14ec7bd21c6cd5bd995272b3faff6/diff")).
|
|
54
|
+
to have_been_made
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
it "should return a diff of a commit" do
|
|
58
|
+
expect(@diff.new_path).to eq("doc/update/5.4-to-6.0.md")
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
describe ".commit_comments" do
|
|
63
|
+
before do
|
|
64
|
+
stub_get("/projects/3/repository/commits/6104942438c14ec7bd21c6cd5bd995272b3faff6/comments", "project_commit_comments")
|
|
65
|
+
@commit_comments = Gitlab.commit_comments(3, '6104942438c14ec7bd21c6cd5bd995272b3faff6')
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
it "should get the correct resource" do
|
|
69
|
+
expect(a_get("/projects/3/repository/commits/6104942438c14ec7bd21c6cd5bd995272b3faff6/comments")).
|
|
70
|
+
to have_been_made
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
it "should return commit's comments" do
|
|
74
|
+
expect(@commit_comments).to be_a Gitlab::PaginatedResponse
|
|
75
|
+
expect(@commit_comments.length).to eq(2)
|
|
76
|
+
expect(@commit_comments[0].note).to eq("this is the 1st comment on commit 6104942438c14ec7bd21c6cd5bd995272b3faff6")
|
|
77
|
+
expect(@commit_comments[0].author.id).to eq(11)
|
|
78
|
+
expect(@commit_comments[1].note).to eq("another discussion point on commit 6104942438c14ec7bd21c6cd5bd995272b3faff6")
|
|
79
|
+
expect(@commit_comments[1].author.id).to eq(12)
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
describe ".create_commit_comment" do
|
|
84
|
+
before do
|
|
85
|
+
stub_post("/projects/3/repository/commits/6104942438c14ec7bd21c6cd5bd995272b3faff6/comments", "project_commit_comment")
|
|
86
|
+
@merge_request = Gitlab.create_commit_comment(3, '6104942438c14ec7bd21c6cd5bd995272b3faff6', 'Nice code!')
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
it "should return information about the newly created comment" do
|
|
90
|
+
expect(@merge_request.note).to eq('Nice code!')
|
|
91
|
+
expect(@merge_request.author.id).to eq(1)
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
describe ".commit_status" do
|
|
96
|
+
before do
|
|
97
|
+
stub_get("/projects/6/repository/commits/7d938cb8ac15788d71f4b67c035515a160ea76d8/statuses", 'project_commit_status').
|
|
98
|
+
with(query: { all: 'true' })
|
|
99
|
+
@statuses = Gitlab.commit_status(6, '7d938cb8ac15788d71f4b67c035515a160ea76d8', all: true)
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
it "should get the correct resource" do
|
|
103
|
+
expect(a_get("/projects/6/repository/commits/7d938cb8ac15788d71f4b67c035515a160ea76d8/statuses").
|
|
104
|
+
with(query: { all: true }))
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
it "should get statuses of a commit" do
|
|
108
|
+
expect(@statuses).to be_kind_of Gitlab::PaginatedResponse
|
|
109
|
+
expect(@statuses.first.sha).to eq('7d938cb8ac15788d71f4b67c035515a160ea76d8')
|
|
110
|
+
expect(@statuses.first.ref).to eq('decreased-spec')
|
|
111
|
+
expect(@statuses.first.status).to eq('failed')
|
|
112
|
+
expect(@statuses.last.sha).to eq('7d938cb8ac15788d71f4b67c035515a160ea76d8')
|
|
113
|
+
expect(@statuses.last.status).to eq('success')
|
|
114
|
+
end
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
describe ".update_commit_status" do
|
|
118
|
+
before do
|
|
119
|
+
stub_post("/projects/6/statuses/7d938cb8ac15788d71f4b67c035515a160ea76d8", 'project_update_commit_status').
|
|
120
|
+
with(query: { name: 'test', ref: 'decreased-spec', state: 'failed' })
|
|
121
|
+
@status = Gitlab.update_commit_status(6, '7d938cb8ac15788d71f4b67c035515a160ea76d8', 'failed', name: 'test', ref: 'decreased-spec')
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
it "should get the correct resource" do
|
|
125
|
+
expect(a_post('/projects/6/statuses/7d938cb8ac15788d71f4b67c035515a160ea76d8').
|
|
126
|
+
with(query: { name: 'test', ref: 'decreased-spec', state: 'failed' }))
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
it "should information about the newly created status" do
|
|
130
|
+
expect(@status).to be_kind_of Gitlab::ObjectifiedHash
|
|
131
|
+
expect(@status.id).to eq(498)
|
|
132
|
+
expect(@status.sha).to eq('7d938cb8ac15788d71f4b67c035515a160ea76d8')
|
|
133
|
+
expect(@status.status).to eq('failed')
|
|
134
|
+
expect(@status.ref).to eq('decreased-spec')
|
|
135
|
+
end
|
|
136
|
+
end
|
|
137
|
+
end
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Gitlab::Client do
|
|
4
|
+
describe ".groups" do
|
|
5
|
+
before do
|
|
6
|
+
stub_get("/groups", "groups")
|
|
7
|
+
stub_get("/groups/3", "group")
|
|
8
|
+
@group = Gitlab.group(3)
|
|
9
|
+
@groups = Gitlab.groups
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
it "should get the correct resource" do
|
|
13
|
+
expect(a_get("/groups")).to have_been_made
|
|
14
|
+
expect(a_get("/groups/3")).to have_been_made
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
it "should return a paginated response of groups" do
|
|
18
|
+
expect(@groups).to be_a Gitlab::PaginatedResponse
|
|
19
|
+
expect(@groups.first.path).to eq("threegroup")
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
describe ".create_group" do
|
|
24
|
+
context "without description" do
|
|
25
|
+
before do
|
|
26
|
+
stub_post("/groups", "group_create")
|
|
27
|
+
@group = Gitlab.create_group('GitLab-Group', 'gitlab-path')
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
it "should get the correct resource" do
|
|
31
|
+
expect(a_post("/groups").
|
|
32
|
+
with(body: { path: 'gitlab-path', name: 'GitLab-Group' })).to have_been_made
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
it "should return information about a created group" do
|
|
36
|
+
expect(@group.name).to eq("Gitlab-Group")
|
|
37
|
+
expect(@group.path).to eq("gitlab-group")
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
context "with description" do
|
|
42
|
+
before do
|
|
43
|
+
stub_post("/groups", "group_create_with_description")
|
|
44
|
+
@group = Gitlab.create_group('GitLab-Group', 'gitlab-path', description: 'gitlab group description')
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
it "should get the correct resource" do
|
|
48
|
+
expect(a_post("/groups").
|
|
49
|
+
with(body: { path: 'gitlab-path', name: 'GitLab-Group',
|
|
50
|
+
description: 'gitlab group description' })).to have_been_made
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
it "should return information about a created group" do
|
|
54
|
+
expect(@group.name).to eq("Gitlab-Group")
|
|
55
|
+
expect(@group.path).to eq("gitlab-group")
|
|
56
|
+
expect(@group.description).to eq("gitlab group description")
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
describe ".delete_group" do
|
|
62
|
+
context "without description" do
|
|
63
|
+
before do
|
|
64
|
+
stub_delete("/groups/42", "group_delete")
|
|
65
|
+
@group = Gitlab.delete_group(42)
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
it "should get the correct resource" do
|
|
69
|
+
expect(a_delete("/groups/42")).to have_been_made
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
it "should return information about a deleted group" do
|
|
73
|
+
expect(@group.name).to eq("Gitlab-Group")
|
|
74
|
+
expect(@group.path).to eq("gitlab-group")
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
describe ".transfer_project_to_group" do
|
|
80
|
+
before do
|
|
81
|
+
stub_post("/projects", "project")
|
|
82
|
+
@project = Gitlab.create_project('Gitlab')
|
|
83
|
+
stub_post("/groups", "group_create")
|
|
84
|
+
@group = Gitlab.create_group('GitLab-Group', 'gitlab-path')
|
|
85
|
+
|
|
86
|
+
stub_post("/groups/#{@group.id}/projects/#{@project.id}", "group_create")
|
|
87
|
+
@group_transfer = Gitlab.transfer_project_to_group(@group.id, @project.id)
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
it "should post to the correct resource" do
|
|
91
|
+
expect(a_post("/groups/#{@group.id}/projects/#{@project.id}").with(body: { id: @group.id.to_s, project_id: @project.id.to_s })).to have_been_made
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
it "should return information about the group" do
|
|
95
|
+
expect(@group_transfer.name).to eq(@group.name)
|
|
96
|
+
expect(@group_transfer.path).to eq(@group.path)
|
|
97
|
+
expect(@group_transfer.id).to eq(@group.id)
|
|
98
|
+
end
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
describe ".group_members" do
|
|
102
|
+
before do
|
|
103
|
+
stub_get("/groups/3/members", "group_members")
|
|
104
|
+
@members = Gitlab.group_members(3)
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
it "should get the correct resource" do
|
|
108
|
+
expect(a_get("/groups/3/members")).to have_been_made
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
it "should return information about a group members" do
|
|
112
|
+
expect(@members).to be_a Gitlab::PaginatedResponse
|
|
113
|
+
expect(@members.size).to eq(2)
|
|
114
|
+
expect(@members[1].name).to eq("John Smith")
|
|
115
|
+
end
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
describe ".add_group_member" do
|
|
119
|
+
before do
|
|
120
|
+
stub_post("/groups/3/members", "group_member")
|
|
121
|
+
@member = Gitlab.add_group_member(3, 1, 40)
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
it "should get the correct resource" do
|
|
125
|
+
expect(a_post("/groups/3/members").
|
|
126
|
+
with(body: { user_id: '1', access_level: '40' })).to have_been_made
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
it "should return information about the added member" do
|
|
130
|
+
expect(@member.name).to eq("John Smith")
|
|
131
|
+
end
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
describe ".edit_group_member" do
|
|
135
|
+
before do
|
|
136
|
+
stub_put("/groups/3/members/1", "group_member_edit")
|
|
137
|
+
@member = Gitlab.edit_group_member(3, 1, 50)
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
it "should get the correct resource" do
|
|
141
|
+
expect(a_put("/groups/3/members/1")
|
|
142
|
+
.with(body: { access_level: '50'})).to have_been_made
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
it "should return information about the edited member" do
|
|
146
|
+
expect(@member.access_level).to eq(50)
|
|
147
|
+
end
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
describe ".remove_group_member" do
|
|
151
|
+
before do
|
|
152
|
+
stub_delete("/groups/3/members/1", "group_member_delete")
|
|
153
|
+
@group = Gitlab.remove_group_member(3, 1)
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
it "should get the correct resource" do
|
|
157
|
+
expect(a_delete("/groups/3/members/1")).to have_been_made
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
it "should return information about the group the member was removed from" do
|
|
161
|
+
expect(@group.group_id).to eq(3)
|
|
162
|
+
end
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
describe ".group_projects" do
|
|
166
|
+
before do
|
|
167
|
+
stub_get("/groups/4/projects", "group_projects")
|
|
168
|
+
@projects = Gitlab.group_projects(4)
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
it "should get the list of projects" do
|
|
172
|
+
expect(a_get("/groups/4/projects")).to have_been_made
|
|
173
|
+
end
|
|
174
|
+
|
|
175
|
+
it "should return a list of of projects under a group" do
|
|
176
|
+
expect(@projects).to be_a Gitlab::PaginatedResponse
|
|
177
|
+
expect(@projects.size).to eq(1)
|
|
178
|
+
expect(@projects[0].name).to eq("Diaspora Client")
|
|
179
|
+
end
|
|
180
|
+
end
|
|
181
|
+
|
|
182
|
+
describe ".group_search" do
|
|
183
|
+
before do
|
|
184
|
+
stub_get("/groups?search=Group", "group_search")
|
|
185
|
+
@groups = Gitlab.group_search('Group')
|
|
186
|
+
end
|
|
187
|
+
|
|
188
|
+
it "should get the correct resource" do
|
|
189
|
+
expect(a_get("/groups?search=Group")).to have_been_made
|
|
190
|
+
end
|
|
191
|
+
|
|
192
|
+
it "should return an array of groups found" do
|
|
193
|
+
expect(@groups.first.id).to eq(5)
|
|
194
|
+
expect(@groups.last.id).to eq(8)
|
|
195
|
+
end
|
|
196
|
+
end
|
|
197
|
+
end
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Gitlab::Client do
|
|
4
|
+
describe ".issues" do
|
|
5
|
+
context "with project ID passed" do
|
|
6
|
+
before do
|
|
7
|
+
stub_get("/projects/3/issues", "project_issues")
|
|
8
|
+
@issues = Gitlab.issues(3)
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
it "should get the correct resource" do
|
|
12
|
+
expect(a_get("/projects/3/issues")).to have_been_made
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
it "should return a paginated response of project's issues" do
|
|
16
|
+
expect(@issues).to be_a Gitlab::PaginatedResponse
|
|
17
|
+
expect(@issues.first.project_id).to eq(3)
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
context "without project ID passed" do
|
|
22
|
+
before do
|
|
23
|
+
stub_get("/issues", "issues")
|
|
24
|
+
@issues = Gitlab.issues
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
it "should get the correct resource" do
|
|
28
|
+
expect(a_get("/issues")).to have_been_made
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
it "should return a paginated response of user's issues" do
|
|
32
|
+
expect(@issues).to be_a Gitlab::PaginatedResponse
|
|
33
|
+
expect(@issues.first.closed).to be_falsey
|
|
34
|
+
expect(@issues.first.author.name).to eq("John Smith")
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
describe ".issue" do
|
|
40
|
+
before do
|
|
41
|
+
stub_get("/projects/3/issues/33", "issue")
|
|
42
|
+
@issue = Gitlab.issue(3, 33)
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
it "should get the correct resource" do
|
|
46
|
+
expect(a_get("/projects/3/issues/33")).to have_been_made
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
it "should return information about an issue" do
|
|
50
|
+
expect(@issue.project_id).to eq(3)
|
|
51
|
+
expect(@issue.assignee.name).to eq("Jack Smith")
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
describe ".create_issue" do
|
|
56
|
+
before do
|
|
57
|
+
stub_post("/projects/3/issues", "issue")
|
|
58
|
+
@issue = Gitlab.create_issue(3, 'title')
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
it "should get the correct resource" do
|
|
62
|
+
expect(a_post("/projects/3/issues").
|
|
63
|
+
with(body: { title: 'title' })).to have_been_made
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
it "should return information about a created issue" do
|
|
67
|
+
expect(@issue.project_id).to eq(3)
|
|
68
|
+
expect(@issue.assignee.name).to eq("Jack Smith")
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
describe ".edit_issue" do
|
|
73
|
+
before do
|
|
74
|
+
stub_put("/projects/3/issues/33", "issue")
|
|
75
|
+
@issue = Gitlab.edit_issue(3, 33, title: 'title')
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
it "should get the correct resource" do
|
|
79
|
+
expect(a_put("/projects/3/issues/33").
|
|
80
|
+
with(body: { title: 'title' })).to have_been_made
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
it "should return information about an edited issue" do
|
|
84
|
+
expect(@issue.project_id).to eq(3)
|
|
85
|
+
expect(@issue.assignee.name).to eq("Jack Smith")
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
describe ".close_issue" do
|
|
90
|
+
before do
|
|
91
|
+
stub_put("/projects/3/issues/33", "issue")
|
|
92
|
+
@issue = Gitlab.close_issue(3, 33)
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
it "should get the correct resource" do
|
|
96
|
+
expect(a_put("/projects/3/issues/33").
|
|
97
|
+
with(body: { state_event: 'close' })).to have_been_made
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
it "should return information about an closed issue" do
|
|
101
|
+
expect(@issue.project_id).to eq(3)
|
|
102
|
+
expect(@issue.assignee.name).to eq("Jack Smith")
|
|
103
|
+
end
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
describe ".reopen_issue" do
|
|
107
|
+
before do
|
|
108
|
+
stub_put("/projects/3/issues/33", "issue")
|
|
109
|
+
@issue = Gitlab.reopen_issue(3, 33)
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
it "should get the correct resource" do
|
|
113
|
+
expect(a_put("/projects/3/issues/33").
|
|
114
|
+
with(body: { state_event: 'reopen' })).to have_been_made
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
it "should return information about an reopened issue" do
|
|
118
|
+
expect(@issue.project_id).to eq(3)
|
|
119
|
+
expect(@issue.assignee.name).to eq("Jack Smith")
|
|
120
|
+
end
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
describe ".delete_issue" do
|
|
124
|
+
before do
|
|
125
|
+
stub_delete("/projects/3/issues/33", "issue")
|
|
126
|
+
@issue = Gitlab.delete_issue(3, 33)
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
it "should get the correct resource" do
|
|
130
|
+
expect(a_delete("/projects/3/issues/33")).to have_been_made
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
it "should return information about a deleted issue" do
|
|
134
|
+
expect(@issue.project_id).to eq(3)
|
|
135
|
+
expect(@issue.id).to eq(33)
|
|
136
|
+
end
|
|
137
|
+
end
|
|
138
|
+
end
|