gitlab 4.2.0 → 4.18.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +4 -2
- data/LICENSE.txt +1 -1
- data/README.md +96 -25
- data/exe/gitlab +5 -1
- data/lib/gitlab/api.rb +8 -3
- data/lib/gitlab/cli.rb +15 -15
- data/lib/gitlab/cli_helpers.rb +63 -61
- data/lib/gitlab/client/access_requests.rb +103 -0
- data/lib/gitlab/client/application_settings.rb +172 -0
- data/lib/gitlab/client/avatar.rb +21 -0
- data/lib/gitlab/client/award_emojis.rb +5 -3
- data/lib/gitlab/client/boards.rb +62 -4
- data/lib/gitlab/client/branches.rb +53 -14
- data/lib/gitlab/client/broadcast_messages.rb +75 -0
- data/lib/gitlab/client/build_variables.rb +78 -9
- data/lib/gitlab/client/builds.rb +13 -11
- data/lib/gitlab/client/commits.rb +89 -19
- data/lib/gitlab/client/container_registry.rb +85 -0
- data/lib/gitlab/client/deployments.rb +34 -0
- data/lib/gitlab/client/environments.rb +5 -3
- data/lib/gitlab/client/epic_issues.rb +23 -0
- data/lib/gitlab/client/epics.rb +73 -0
- data/lib/gitlab/client/events.rb +60 -0
- data/lib/gitlab/client/features.rb +48 -0
- data/lib/gitlab/client/group_badges.rb +88 -0
- data/lib/gitlab/client/group_boards.rb +141 -0
- data/lib/gitlab/client/group_labels.rb +88 -0
- data/lib/gitlab/client/group_milestones.rb +94 -0
- data/lib/gitlab/client/groups.rb +197 -17
- data/lib/gitlab/client/issue_links.rb +48 -0
- data/lib/gitlab/client/issues.rb +98 -4
- data/lib/gitlab/client/jobs.rb +96 -8
- data/lib/gitlab/client/keys.rb +13 -0
- data/lib/gitlab/client/labels.rb +7 -5
- data/lib/gitlab/client/lint.rb +19 -0
- data/lib/gitlab/client/markdown.rb +23 -0
- data/lib/gitlab/client/merge_request_approvals.rb +265 -0
- data/lib/gitlab/client/merge_requests.rb +237 -9
- data/lib/gitlab/client/milestones.rb +19 -5
- data/lib/gitlab/client/namespaces.rb +4 -2
- data/lib/gitlab/client/notes.rb +58 -12
- data/lib/gitlab/client/pipeline_schedules.rb +147 -0
- data/lib/gitlab/client/pipeline_triggers.rb +12 -10
- data/lib/gitlab/client/pipelines.rb +40 -3
- data/lib/gitlab/client/project_badges.rb +85 -0
- data/lib/gitlab/client/project_clusters.rb +83 -0
- data/lib/gitlab/client/project_release_links.rb +76 -0
- data/lib/gitlab/client/project_releases.rb +79 -0
- data/lib/gitlab/client/projects.rb +280 -47
- data/lib/gitlab/client/protected_tags.rb +59 -0
- data/lib/gitlab/client/remote_mirrors.rb +51 -0
- data/lib/gitlab/client/repositories.rb +60 -6
- data/lib/gitlab/client/repository_files.rb +23 -5
- data/lib/gitlab/client/repository_submodules.rb +27 -0
- data/lib/gitlab/client/resource_label_events.rb +82 -0
- data/lib/gitlab/client/resource_state_events.rb +57 -0
- data/lib/gitlab/client/runners.rb +111 -15
- data/lib/gitlab/client/search.rb +66 -0
- data/lib/gitlab/client/services.rb +4 -1
- data/lib/gitlab/client/sidekiq.rb +39 -0
- data/lib/gitlab/client/snippets.rb +8 -4
- data/lib/gitlab/client/system_hooks.rb +9 -7
- data/lib/gitlab/client/tags.rb +15 -14
- data/lib/gitlab/client/templates.rb +100 -0
- data/lib/gitlab/client/todos.rb +7 -5
- data/lib/gitlab/client/user_snippets.rb +114 -0
- data/lib/gitlab/client/users.rb +166 -30
- data/lib/gitlab/client/versions.rb +18 -0
- data/lib/gitlab/client/wikis.rb +79 -0
- data/lib/gitlab/client.rb +49 -12
- data/lib/gitlab/configuration.rb +8 -6
- data/lib/gitlab/error.rb +74 -5
- data/lib/gitlab/file_response.rb +5 -3
- data/lib/gitlab/help.rb +19 -20
- data/lib/gitlab/objectified_hash.rb +27 -10
- data/lib/gitlab/page_links.rb +11 -9
- data/lib/gitlab/paginated_response.rb +37 -24
- data/lib/gitlab/request.rb +42 -53
- data/lib/gitlab/shell.rb +11 -12
- data/lib/gitlab/shell_history.rb +11 -13
- data/lib/gitlab/version.rb +3 -1
- data/lib/gitlab.rb +19 -8
- metadata +50 -395
- data/.gitignore +0 -22
- data/.travis.yml +0 -8
- data/CONTRIBUTING.md +0 -195
- data/Gemfile +0 -4
- data/Rakefile +0 -9
- data/bin/console +0 -10
- data/bin/setup +0 -6
- data/gitlab.gemspec +0 -31
- data/spec/fixtures/board_list.json +0 -1
- data/spec/fixtures/board_lists.json +0 -1
- data/spec/fixtures/boards.json +0 -1
- data/spec/fixtures/branch.json +0 -1
- data/spec/fixtures/branch_delete.json +0 -3
- data/spec/fixtures/branches.json +0 -1
- data/spec/fixtures/build.json +0 -38
- data/spec/fixtures/build_artifacts.json +0 -0
- data/spec/fixtures/build_cancel.json +0 -24
- data/spec/fixtures/build_erase.json +0 -24
- data/spec/fixtures/build_retry.json +0 -24
- data/spec/fixtures/builds.json +0 -78
- data/spec/fixtures/builds_commits.json +0 -64
- data/spec/fixtures/compare_merge_request_diff.json +0 -31
- data/spec/fixtures/empty.json +0 -0
- data/spec/fixtures/environment.json +0 -6
- data/spec/fixtures/environments.json +0 -14
- data/spec/fixtures/error_already_exists.json +0 -1
- data/spec/fixtures/error_project_not_found.json +0 -1
- data/spec/fixtures/get_repository_file.json +0 -1
- data/spec/fixtures/group.json +0 -60
- data/spec/fixtures/group_create.json +0 -1
- data/spec/fixtures/group_create_with_description.json +0 -1
- data/spec/fixtures/group_delete.json +0 -1
- data/spec/fixtures/group_member.json +0 -1
- data/spec/fixtures/group_member_delete.json +0 -1
- data/spec/fixtures/group_member_edit.json +0 -1
- data/spec/fixtures/group_members.json +0 -1
- data/spec/fixtures/group_projects.json +0 -44
- data/spec/fixtures/group_search.json +0 -2
- data/spec/fixtures/groups.json +0 -2
- data/spec/fixtures/issue.json +0 -1
- data/spec/fixtures/issue_award_emoji.json +0 -16
- data/spec/fixtures/issue_award_emojis.json +0 -34
- data/spec/fixtures/issues.json +0 -1
- data/spec/fixtures/job.json +0 -43
- data/spec/fixtures/job_trace.json +0 -1
- data/spec/fixtures/jobs.json +0 -91
- data/spec/fixtures/key.json +0 -1
- data/spec/fixtures/keys.json +0 -1
- data/spec/fixtures/label.json +0 -1
- data/spec/fixtures/label_unsubscribe.json +0 -1
- data/spec/fixtures/labels.json +0 -1
- data/spec/fixtures/merge_request.json +0 -1
- data/spec/fixtures/merge_request_award_emoji.json +0 -16
- data/spec/fixtures/merge_request_award_emojis.json +0 -34
- data/spec/fixtures/merge_request_changes.json +0 -1
- data/spec/fixtures/merge_request_closes_issues.json +0 -1
- data/spec/fixtures/merge_request_comment.json +0 -1
- data/spec/fixtures/merge_request_comments.json +0 -1
- data/spec/fixtures/merge_request_commits.json +0 -1
- data/spec/fixtures/merge_requests.json +0 -1
- data/spec/fixtures/milestone.json +0 -1
- data/spec/fixtures/milestone_issues.json +0 -1
- data/spec/fixtures/milestone_merge_requests.json +0 -1
- data/spec/fixtures/milestones.json +0 -1
- data/spec/fixtures/namespaces.json +0 -1
- data/spec/fixtures/note.json +0 -1
- data/spec/fixtures/note_award_emoji.json +0 -16
- data/spec/fixtures/note_award_emojis.json +0 -18
- data/spec/fixtures/notes.json +0 -1
- data/spec/fixtures/pipeline.json +0 -23
- data/spec/fixtures/pipeline_cancel.json +0 -23
- data/spec/fixtures/pipeline_create.json +0 -23
- data/spec/fixtures/pipeline_jobs.json +0 -91
- data/spec/fixtures/pipeline_retry.json +0 -23
- data/spec/fixtures/pipelines.json +0 -48
- data/spec/fixtures/project.json +0 -1
- data/spec/fixtures/project_commit.json +0 -13
- data/spec/fixtures/project_commit_comment.json +0 -1
- data/spec/fixtures/project_commit_comments.json +0 -1
- data/spec/fixtures/project_commit_create.json +0 -22
- data/spec/fixtures/project_commit_diff.json +0 -10
- data/spec/fixtures/project_commit_status.json +0 -42
- data/spec/fixtures/project_commits.json +0 -1
- data/spec/fixtures/project_edit.json +0 -21
- data/spec/fixtures/project_events.json +0 -1
- data/spec/fixtures/project_for_user.json +0 -1
- data/spec/fixtures/project_fork.json +0 -50
- data/spec/fixtures/project_fork_link.json +0 -1
- data/spec/fixtures/project_forked_for_user.json +0 -50
- data/spec/fixtures/project_hook.json +0 -1
- data/spec/fixtures/project_hooks.json +0 -1
- data/spec/fixtures/project_issues.json +0 -1
- data/spec/fixtures/project_key.json +0 -6
- data/spec/fixtures/project_keys.json +0 -6
- data/spec/fixtures/project_runner_enable.json +0 -7
- data/spec/fixtures/project_runners.json +0 -16
- data/spec/fixtures/project_search.json +0 -1
- data/spec/fixtures/project_star.json +0 -44
- data/spec/fixtures/project_tag_annotated.json +0 -1
- data/spec/fixtures/project_tag_lightweight.json +0 -1
- data/spec/fixtures/project_tags.json +0 -1
- data/spec/fixtures/project_unstar.json +0 -44
- data/spec/fixtures/project_update_commit_status.json +0 -20
- data/spec/fixtures/projects.json +0 -1
- data/spec/fixtures/push_rule.json +0 -1
- data/spec/fixtures/raw_file.json +0 -2
- data/spec/fixtures/release_create.json +0 -1
- data/spec/fixtures/release_update.json +0 -1
- data/spec/fixtures/repository_file.json +0 -1
- data/spec/fixtures/run_trigger.json +0 -1
- data/spec/fixtures/runner.json +0 -26
- data/spec/fixtures/runner_delete.json +0 -7
- data/spec/fixtures/runner_edit.json +0 -26
- data/spec/fixtures/runners.json +0 -16
- data/spec/fixtures/runners_all.json +0 -30
- data/spec/fixtures/service.json +0 -1
- data/spec/fixtures/session.json +0 -1
- data/spec/fixtures/shell_history.json +0 -2
- data/spec/fixtures/snippet.json +0 -1
- data/spec/fixtures/snippet_award_emoji.json +0 -16
- data/spec/fixtures/snippet_award_emojis.json +0 -34
- data/spec/fixtures/snippet_content.json +0 -3
- data/spec/fixtures/snippets.json +0 -1
- data/spec/fixtures/system_hook.json +0 -1
- data/spec/fixtures/system_hooks.json +0 -1
- data/spec/fixtures/tag.json +0 -1
- data/spec/fixtures/tag_create.json +0 -1
- data/spec/fixtures/tag_create_with_description.json +0 -1
- data/spec/fixtures/tag_delete.json +0 -1
- data/spec/fixtures/tags.json +0 -1
- data/spec/fixtures/team_member.json +0 -1
- data/spec/fixtures/team_members.json +0 -1
- data/spec/fixtures/todo.json +0 -73
- data/spec/fixtures/todos.json +0 -148
- data/spec/fixtures/tree.json +0 -1
- data/spec/fixtures/trigger.json +0 -10
- data/spec/fixtures/triggers.json +0 -12
- data/spec/fixtures/user.json +0 -1
- data/spec/fixtures/user_block_unblock.json +0 -1
- data/spec/fixtures/user_email.json +0 -1
- data/spec/fixtures/user_emails.json +0 -1
- data/spec/fixtures/user_search.json +0 -1
- data/spec/fixtures/users.json +0 -1
- data/spec/fixtures/variable.json +0 -4
- data/spec/fixtures/variables.json +0 -10
- data/spec/gitlab/cli_helpers_spec.rb +0 -57
- data/spec/gitlab/cli_spec.rb +0 -119
- data/spec/gitlab/client/award_emojis_spec.rb +0 -391
- data/spec/gitlab/client/boards_spec.rb +0 -94
- data/spec/gitlab/client/branches_spec.rb +0 -116
- data/spec/gitlab/client/build_variables_spec.rb +0 -86
- data/spec/gitlab/client/builds_spec.rb +0 -148
- data/spec/gitlab/client/client_spec.rb +0 -11
- data/spec/gitlab/client/commits_spec.rb +0 -168
- data/spec/gitlab/client/environments_spec.rb +0 -132
- data/spec/gitlab/client/groups_spec.rb +0 -195
- data/spec/gitlab/client/issues_spec.rb +0 -186
- data/spec/gitlab/client/jobs_spec.rb +0 -135
- data/spec/gitlab/client/keys_spec.rb +0 -19
- data/spec/gitlab/client/labels_spec.rb +0 -100
- data/spec/gitlab/client/merge_requests_spec.rb +0 -224
- data/spec/gitlab/client/milestones_spec.rb +0 -98
- data/spec/gitlab/client/namespaces_spec.rb +0 -22
- data/spec/gitlab/client/notes_spec.rb +0 -333
- data/spec/gitlab/client/pipeline_triggers_spec.rb +0 -157
- data/spec/gitlab/client/pipelines_spec.rb +0 -95
- data/spec/gitlab/client/projects_spec.rb +0 -613
- data/spec/gitlab/client/repositories_spec.rb +0 -94
- data/spec/gitlab/client/repository_files_spec.rb +0 -95
- data/spec/gitlab/client/runners_spec.rb +0 -185
- data/spec/gitlab/client/services_spec.rb +0 -55
- data/spec/gitlab/client/snippets_spec.rb +0 -100
- data/spec/gitlab/client/system_hooks_spec.rb +0 -69
- data/spec/gitlab/client/tags_spec.rb +0 -109
- data/spec/gitlab/client/todos_spec.rb +0 -45
- data/spec/gitlab/client/users_spec.rb +0 -418
- data/spec/gitlab/error_spec.rb +0 -45
- data/spec/gitlab/file_response_spec.rb +0 -33
- data/spec/gitlab/help_spec.rb +0 -46
- data/spec/gitlab/objectified_hash_spec.rb +0 -48
- data/spec/gitlab/page_links_spec.rb +0 -16
- data/spec/gitlab/paginated_response_spec.rb +0 -60
- data/spec/gitlab/request_spec.rb +0 -73
- data/spec/gitlab/shell_history_spec.rb +0 -53
- data/spec/gitlab/shell_spec.rb +0 -80
- data/spec/gitlab_spec.rb +0 -97
- data/spec/spec_helper.rb +0 -74
data/spec/gitlab/request_spec.rb
DELETED
@@ -1,73 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Gitlab::Request do
|
4
|
-
it { should respond_to :get }
|
5
|
-
it { should respond_to :post }
|
6
|
-
it { should respond_to :put }
|
7
|
-
it { should respond_to :delete }
|
8
|
-
before do
|
9
|
-
@request = Gitlab::Request.new
|
10
|
-
end
|
11
|
-
|
12
|
-
describe ".default_options" do
|
13
|
-
it "should have default values" do
|
14
|
-
default_options = Gitlab::Request.default_options
|
15
|
-
expect(default_options).to be_a Hash
|
16
|
-
expect(default_options[:parser]).to be_a Proc
|
17
|
-
expect(default_options[:format]).to eq(:json)
|
18
|
-
expect(default_options[:headers]).to eq('Accept' => 'application/json', 'Content-Type' => 'application/x-www-form-urlencoded')
|
19
|
-
expect(default_options[:default_params]).to be_nil
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
describe ".parse" do
|
24
|
-
it "should return ObjectifiedHash" do
|
25
|
-
body = JSON.unparse(a: 1, b: 2)
|
26
|
-
expect(Gitlab::Request.parse(body)).to be_an Gitlab::ObjectifiedHash
|
27
|
-
expect(Gitlab::Request.parse("true")).to be true
|
28
|
-
expect(Gitlab::Request.parse("false")).to be false
|
29
|
-
|
30
|
-
expect { Gitlab::Request.parse("string") }.to raise_error(Gitlab::Error::Parsing)
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
describe "#set_request_defaults" do
|
35
|
-
context "when endpoint is not set" do
|
36
|
-
it "should raise Error::MissingCredentials" do
|
37
|
-
@request.endpoint = nil
|
38
|
-
expect do
|
39
|
-
@request.set_request_defaults
|
40
|
-
end.to raise_error(Gitlab::Error::MissingCredentials, 'Please set an endpoint to API')
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
context "when endpoint is set" do
|
45
|
-
before(:each) do
|
46
|
-
@request.endpoint = 'http://rabbit-hole.example.org'
|
47
|
-
end
|
48
|
-
|
49
|
-
it "should set default_params" do
|
50
|
-
@request.set_request_defaults('sudoer')
|
51
|
-
expect(Gitlab::Request.default_params).to eq(sudo: 'sudoer')
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
describe "#set_authorization_header" do
|
57
|
-
it "should raise MissingCredentials when auth_token and private_token are not set" do
|
58
|
-
expect do
|
59
|
-
@request.send(:set_authorization_header, {})
|
60
|
-
end.to raise_error(Gitlab::Error::MissingCredentials)
|
61
|
-
end
|
62
|
-
|
63
|
-
it "should set the correct header when given a private_token" do
|
64
|
-
@request.private_token = 'ys9BtunN3rDKbaJCYXaN'
|
65
|
-
expect(@request.send(:set_authorization_header, {})).to eq("PRIVATE-TOKEN" => 'ys9BtunN3rDKbaJCYXaN')
|
66
|
-
end
|
67
|
-
|
68
|
-
it "should set the correct header when setting an auth_token via the private_token config option" do
|
69
|
-
@request.private_token = '3225e2804d31fea13fc41fc83bffef00cfaedc463118646b154acc6f94747603'
|
70
|
-
expect(@request.send(:set_authorization_header, {})).to eq("Authorization" => "Bearer 3225e2804d31fea13fc41fc83bffef00cfaedc463118646b154acc6f94747603")
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|
@@ -1,53 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'tempfile'
|
3
|
-
|
4
|
-
describe Gitlab::Shell::History do
|
5
|
-
context 'saving to a file' do
|
6
|
-
before do
|
7
|
-
@file = Tempfile.new('.gitlab_shell_history')
|
8
|
-
@history = Gitlab::Shell::History.new(file_path: @file.path)
|
9
|
-
end
|
10
|
-
|
11
|
-
after { @file.close(true) }
|
12
|
-
|
13
|
-
it 'saves the lines' do
|
14
|
-
@history << 'party on, dudes'
|
15
|
-
@history << 'be excellent to each other'
|
16
|
-
@history.save
|
17
|
-
expect(File.read @file.path).
|
18
|
-
to eq("party on, dudes\nbe excellent to each other\n")
|
19
|
-
end
|
20
|
-
|
21
|
-
it 'has the lines' do
|
22
|
-
@history << 'party on, dudes'
|
23
|
-
@history << 'be excellent to each other'
|
24
|
-
expect(@history.lines).
|
25
|
-
to eq(["party on, dudes", "be excellent to each other"])
|
26
|
-
end
|
27
|
-
|
28
|
-
it 'limits the lines to GITLAB_HISTFILESIZE' do
|
29
|
-
ENV['GITLAB_HISTFILESIZE'] = '2'
|
30
|
-
@history << 'bogus'
|
31
|
-
@history << 'party on, dudes'
|
32
|
-
@history << 'be excellent to each other'
|
33
|
-
@history.save
|
34
|
-
expect(@history.lines).
|
35
|
-
to eq(["party on, dudes", "be excellent to each other"])
|
36
|
-
expect(File.read @file.path).
|
37
|
-
to eq("party on, dudes\nbe excellent to each other\n")
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
context 'loading a file' do
|
42
|
-
before do
|
43
|
-
@file = load_fixture('shell_history')
|
44
|
-
@history = Gitlab::Shell::History.new(file_path: @file.path)
|
45
|
-
end
|
46
|
-
|
47
|
-
it 'has the lines' do
|
48
|
-
@history.load
|
49
|
-
expect(@history.lines).
|
50
|
-
to eq(["party on, dudes", "be excellent to each other"])
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
data/spec/gitlab/shell_spec.rb
DELETED
@@ -1,80 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Gitlab::Shell do
|
4
|
-
before do
|
5
|
-
Gitlab::Shell.setup
|
6
|
-
end
|
7
|
-
|
8
|
-
describe ".execute" do
|
9
|
-
context "invalid command" do
|
10
|
-
it "should raise" do
|
11
|
-
expect { Gitlab::Shell.execute 'foobar', [] }.to raise_error(RuntimeError)
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
describe ".history" do
|
17
|
-
before do
|
18
|
-
@history = Gitlab::Shell.history
|
19
|
-
end
|
20
|
-
|
21
|
-
it "should return a Gitlab::Shell::History instance" do
|
22
|
-
expect(@history).to be_a Gitlab::Shell::History
|
23
|
-
end
|
24
|
-
it "should respond to :save" do
|
25
|
-
expect(@history).to respond_to :save
|
26
|
-
end
|
27
|
-
it "should respond to :load" do
|
28
|
-
expect(@history).to respond_to :load
|
29
|
-
end
|
30
|
-
it "should respond to :<<" do
|
31
|
-
expect(@history).to respond_to :<<
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
describe ".setup" do
|
36
|
-
it "should set the Readline completion_proc" do
|
37
|
-
completion = Readline.completion_proc
|
38
|
-
expect(completion).to be_truthy
|
39
|
-
expect(completion).to be_a Proc
|
40
|
-
end
|
41
|
-
it "should set the Readline completion_append_character" do
|
42
|
-
completion_character = Readline.completion_append_character
|
43
|
-
expect(completion_character).to eq(' ')
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
describe ".completion" do
|
48
|
-
before do
|
49
|
-
@comp = Gitlab::Shell.completion
|
50
|
-
end
|
51
|
-
it "should return a Proc object" do
|
52
|
-
expect(@comp).to be_a Proc
|
53
|
-
end
|
54
|
-
context "called with an argument" do
|
55
|
-
it "should return an Array of matching commands" do
|
56
|
-
completed_cmds = @comp.call 'group'
|
57
|
-
expect(completed_cmds).to be_a Array
|
58
|
-
expect(completed_cmds.sort).to eq(%w(group group_members group_projects group_search groups))
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
describe ".parse_input" do
|
64
|
-
context "with arguments" do
|
65
|
-
it "should set command & arguments" do
|
66
|
-
Gitlab::Shell.parse_input('create_branch 1 "api" "master"')
|
67
|
-
expect(Gitlab::Shell.command).to eq('create_branch')
|
68
|
-
expect(Gitlab::Shell.arguments).to eq(%w(1 api master))
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
context "without arguments" do
|
73
|
-
it 'should set command & empty arguments' do
|
74
|
-
Gitlab::Shell.parse_input('exit')
|
75
|
-
expect(Gitlab::Shell.command).to eq('exit')
|
76
|
-
expect(Gitlab::Shell.arguments).to be_empty
|
77
|
-
end
|
78
|
-
end
|
79
|
-
end
|
80
|
-
end
|
data/spec/gitlab_spec.rb
DELETED
@@ -1,97 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Gitlab do
|
4
|
-
after { Gitlab.reset }
|
5
|
-
|
6
|
-
describe ".client" do
|
7
|
-
it "should be a Gitlab::Client" do
|
8
|
-
expect(Gitlab.client).to be_a Gitlab::Client
|
9
|
-
end
|
10
|
-
|
11
|
-
it "should not override each other" do
|
12
|
-
client1 = Gitlab.client(endpoint: 'https://api1.example.com', private_token: '001')
|
13
|
-
client2 = Gitlab.client(endpoint: 'https://api2.example.com', private_token: '002')
|
14
|
-
expect(client1.endpoint).to eq('https://api1.example.com')
|
15
|
-
expect(client2.endpoint).to eq('https://api2.example.com')
|
16
|
-
expect(client1.private_token).to eq('001')
|
17
|
-
expect(client2.private_token).to eq('002')
|
18
|
-
end
|
19
|
-
|
20
|
-
it "should set private_token to the auth_token when provided" do
|
21
|
-
client = Gitlab.client(endpoint: 'https://api2.example.com', auth_token: '3225e2804d31fea13fc41fc83bffef00cfaedc463118646b154acc6f94747603')
|
22
|
-
expect(client.private_token).to eq('3225e2804d31fea13fc41fc83bffef00cfaedc463118646b154acc6f94747603')
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
describe ".actions" do
|
27
|
-
it "should return an array of client methods" do
|
28
|
-
actions = Gitlab.actions
|
29
|
-
expect(actions).to be_an Array
|
30
|
-
expect(actions.first).to be_a Symbol
|
31
|
-
expect(actions.sort.first).to eq(:accept_merge_request)
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
describe ".endpoint=" do
|
36
|
-
it "should set endpoint" do
|
37
|
-
Gitlab.endpoint = 'https://api.example.com'
|
38
|
-
expect(Gitlab.endpoint).to eq('https://api.example.com')
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
describe ".private_token=" do
|
43
|
-
it "should set private_token" do
|
44
|
-
Gitlab.private_token = 'secret'
|
45
|
-
expect(Gitlab.private_token).to eq('secret')
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
describe ".auth_token=" do
|
50
|
-
it "should set auth_token", focus: true do
|
51
|
-
Gitlab.auth_token = 'auth_secret'
|
52
|
-
expect(Gitlab.private_token).to eq('auth_secret')
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
describe ".sudo=" do
|
57
|
-
it "should set sudo" do
|
58
|
-
Gitlab.sudo = 'user'
|
59
|
-
expect(Gitlab.sudo).to eq('user')
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
describe ".user_agent" do
|
64
|
-
it "should return default user_agent" do
|
65
|
-
expect(Gitlab.user_agent).to eq(Gitlab::Configuration::DEFAULT_USER_AGENT)
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
describe ".user_agent=" do
|
70
|
-
it "should set user_agent" do
|
71
|
-
Gitlab.user_agent = 'Custom User Agent'
|
72
|
-
expect(Gitlab.user_agent).to eq('Custom User Agent')
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
describe ".configure" do
|
77
|
-
Gitlab::Configuration::VALID_OPTIONS_KEYS.each do |key|
|
78
|
-
it "should set #{key}" do
|
79
|
-
Gitlab.configure do |config|
|
80
|
-
config.send("#{key}=", key)
|
81
|
-
expect(Gitlab.send(key)).to eq(key)
|
82
|
-
end
|
83
|
-
end
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
describe ".http_proxy" do
|
88
|
-
it "delegates the method to Gitlab::Request" do
|
89
|
-
Gitlab.endpoint = 'https://api.example.com'
|
90
|
-
request = class_spy(Gitlab::Request).as_stubbed_const
|
91
|
-
|
92
|
-
Gitlab.http_proxy('fazbearentertainment.com', 1987, 'ffazbear', 'itsme')
|
93
|
-
expect(request).to have_received(:http_proxy).
|
94
|
-
with('fazbearentertainment.com', 1987, 'ffazbear', 'itsme')
|
95
|
-
end
|
96
|
-
end
|
97
|
-
end
|
data/spec/spec_helper.rb
DELETED
@@ -1,74 +0,0 @@
|
|
1
|
-
require 'rspec'
|
2
|
-
require 'webmock/rspec'
|
3
|
-
|
4
|
-
require File.expand_path('../../lib/gitlab', __FILE__)
|
5
|
-
require File.expand_path('../../lib/gitlab/cli', __FILE__)
|
6
|
-
|
7
|
-
def capture_output
|
8
|
-
out = StringIO.new
|
9
|
-
$stdout = out
|
10
|
-
$stderr = out
|
11
|
-
yield
|
12
|
-
$stdout = STDOUT
|
13
|
-
$stderr = STDERR
|
14
|
-
out.string
|
15
|
-
end
|
16
|
-
|
17
|
-
def load_fixture(name)
|
18
|
-
File.new(File.dirname(__FILE__) + "/fixtures/#{name}.json")
|
19
|
-
end
|
20
|
-
|
21
|
-
RSpec.configure do |config|
|
22
|
-
config.before(:all) do
|
23
|
-
Gitlab.endpoint = 'https://api.example.com'
|
24
|
-
Gitlab.private_token = 'secret'
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
# GET
|
29
|
-
def stub_get(path, fixture, status_code=200)
|
30
|
-
stub_request(:get, "#{Gitlab.endpoint}#{path}").
|
31
|
-
with(headers: { 'PRIVATE-TOKEN' => Gitlab.private_token }).
|
32
|
-
to_return(body: load_fixture(fixture), status: status_code)
|
33
|
-
end
|
34
|
-
|
35
|
-
def a_get(path)
|
36
|
-
a_request(:get, "#{Gitlab.endpoint}#{path}").
|
37
|
-
with(headers: { 'PRIVATE-TOKEN' => Gitlab.private_token })
|
38
|
-
end
|
39
|
-
|
40
|
-
# POST
|
41
|
-
def stub_post(path, fixture, status_code=200)
|
42
|
-
stub_request(:post, "#{Gitlab.endpoint}#{path}").
|
43
|
-
with(headers: { 'PRIVATE-TOKEN' => Gitlab.private_token }).
|
44
|
-
to_return(body: load_fixture(fixture), status: status_code)
|
45
|
-
end
|
46
|
-
|
47
|
-
def a_post(path)
|
48
|
-
a_request(:post, "#{Gitlab.endpoint}#{path}").
|
49
|
-
with(headers: { 'PRIVATE-TOKEN' => Gitlab.private_token })
|
50
|
-
end
|
51
|
-
|
52
|
-
# PUT
|
53
|
-
def stub_put(path, fixture)
|
54
|
-
stub_request(:put, "#{Gitlab.endpoint}#{path}").
|
55
|
-
with(headers: { 'PRIVATE-TOKEN' => Gitlab.private_token }).
|
56
|
-
to_return(body: load_fixture(fixture))
|
57
|
-
end
|
58
|
-
|
59
|
-
def a_put(path)
|
60
|
-
a_request(:put, "#{Gitlab.endpoint}#{path}").
|
61
|
-
with(headers: { 'PRIVATE-TOKEN' => Gitlab.private_token })
|
62
|
-
end
|
63
|
-
|
64
|
-
# DELETE
|
65
|
-
def stub_delete(path, fixture)
|
66
|
-
stub_request(:delete, "#{Gitlab.endpoint}#{path}").
|
67
|
-
with(headers: { 'PRIVATE-TOKEN' => Gitlab.private_token }).
|
68
|
-
to_return(body: load_fixture(fixture))
|
69
|
-
end
|
70
|
-
|
71
|
-
def a_delete(path)
|
72
|
-
a_request(:delete, "#{Gitlab.endpoint}#{path}").
|
73
|
-
with(headers: { 'PRIVATE-TOKEN' => Gitlab.private_token })
|
74
|
-
end
|