gitlab 4.4.0 → 4.5.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 +4 -4
- data/CHANGELOG.md +4 -2
- data/gitlab.gemspec +3 -1
- data/lib/gitlab/client.rb +1 -0
- data/lib/gitlab/client/merge_request_approvals.rb +110 -0
- data/lib/gitlab/client/projects.rb +19 -9
- data/lib/gitlab/error.rb +10 -3
- data/lib/gitlab/version.rb +1 -1
- metadata +5 -444
- data/.dockerignore +0 -6
- data/.rubocop.yml +0 -33
- data/.travis.yml +0 -13
- data/Dockerfile +0 -8
- data/docker-compose.yml +0 -19
- data/docker.env +0 -2
- data/spec/fixtures/access_request.json +0 -8
- data/spec/fixtures/access_requests.json +0 -18
- data/spec/fixtures/approved_access_request.json +0 -8
- 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/default_approved_access_request.json +0 -8
- data/spec/fixtures/deployment.json +0 -57
- data/spec/fixtures/deployments.json +0 -116
- 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_edit.json +0 -14
- 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_milestone.json +0 -1
- data/spec/fixtures/group_milestone_issues.json +0 -1
- data/spec/fixtures/group_milestone_merge_requests.json +0 -1
- data/spec/fixtures/group_milestones.json +0 -1
- data/spec/fixtures/group_projects.json +0 -44
- data/spec/fixtures/group_search.json +0 -2
- data/spec/fixtures/group_subgroups.json +0 -16
- 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_request_discussion.json +0 -39
- data/spec/fixtures/merge_request_discussion_note.json +0 -33
- data/spec/fixtures/merge_request_discussions.json +0 -41
- 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/pipeline_schedule.json +0 -32
- data/spec/fixtures/pipeline_schedule_create.json +0 -21
- data/spec/fixtures/pipeline_schedule_update.json +0 -26
- data/spec/fixtures/pipeline_schedule_variable.json +0 -5
- data/spec/fixtures/pipeline_schedule_variable_update.json +0 -5
- data/spec/fixtures/pipeline_schedules.json +0 -22
- 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_merge_requests.json +0 -1
- 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 -81
- 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_forks.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/runner_jobs.json +0 -63
- 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/sidekiq_compound_metrics.json +0 -36
- data/spec/fixtures/sidekiq_job_stats.json +0 -7
- data/spec/fixtures/sidekiq_process_metrics.json +0 -25
- data/spec/fixtures/sidekiq_queue_metrics.json +0 -8
- 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_contribution_events.json +0 -101
- data/spec/fixtures/user_email.json +0 -1
- data/spec/fixtures/user_emails.json +0 -1
- data/spec/fixtures/user_events.json +0 -40
- data/spec/fixtures/user_projects.json +0 -153
- 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/api_spec.rb +0 -11
- data/spec/gitlab/cli_helpers_spec.rb +0 -56
- data/spec/gitlab/cli_spec.rb +0 -119
- data/spec/gitlab/client/access_requests_spec.rb +0 -141
- 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 -118
- data/spec/gitlab/client/build_variables_spec.rb +0 -169
- 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 -190
- data/spec/gitlab/client/deployments_spec.rb +0 -38
- data/spec/gitlab/client/environments_spec.rb +0 -132
- data/spec/gitlab/client/events_spec.rb +0 -48
- data/spec/gitlab/client/group_milestones_spec.rb +0 -98
- data/spec/gitlab/client/groups_spec.rb +0 -246
- data/spec/gitlab/client/issues_spec.rb +0 -285
- 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 -351
- 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_schedules_spec.rb +0 -158
- 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 -630
- 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 -193
- data/spec/gitlab/client/services_spec.rb +0 -55
- data/spec/gitlab/client/sidekiq_spec.rb +0 -64
- 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 -152
- 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 -72
- 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 -96
- data/spec/spec_helper.rb +0 -39
data/spec/gitlab/error_spec.rb
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
require "spec_helper"
|
|
2
|
-
require "stringio"
|
|
3
|
-
|
|
4
|
-
describe Gitlab::Error do
|
|
5
|
-
let(:request_object) { HTTParty::Request.new(Net::HTTP::Get, '/') }
|
|
6
|
-
let(:response_object) { Net::HTTPOK.new('1.1', 200, 'OK') }
|
|
7
|
-
let(:body) { StringIO.new("{foo:'bar'}") }
|
|
8
|
-
let(:parsed_response) { -> { body } }
|
|
9
|
-
|
|
10
|
-
let(:response) do
|
|
11
|
-
HTTParty::Response.new(
|
|
12
|
-
request_object,
|
|
13
|
-
response_object,
|
|
14
|
-
parsed_response,
|
|
15
|
-
body: body
|
|
16
|
-
)
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
let(:error) { Gitlab::Error::ResponseError.new(response) }
|
|
20
|
-
let(:date) { Date.new(2010, 1, 15).to_s }
|
|
21
|
-
|
|
22
|
-
before do
|
|
23
|
-
def body.message
|
|
24
|
-
string
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
response_object['last-modified'] = date
|
|
28
|
-
response_object['content-length'] = "1024"
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
describe "#handle_message" do
|
|
32
|
-
let(:array) { Array.new(['First message.', 'Second message.']) }
|
|
33
|
-
let(:obj_h) do
|
|
34
|
-
Gitlab::ObjectifiedHash.new(
|
|
35
|
-
user: ['not set'],
|
|
36
|
-
password: ['too short'],
|
|
37
|
-
embed_entity: { foo: ['bar'], sna: ['fu'] }
|
|
38
|
-
)
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
context "when passed an ObjectifiedHash" do
|
|
42
|
-
it "returns a joined string of error messages sorted by key" do
|
|
43
|
-
expect(error.send(:handle_message, obj_h)).
|
|
44
|
-
to eq(
|
|
45
|
-
"'embed_entity' (foo: bar) (sna: fu), 'password' too short, 'user' not set"
|
|
46
|
-
)
|
|
47
|
-
end
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
context "when passed an Array" do
|
|
51
|
-
it "returns a joined string of messages" do
|
|
52
|
-
expect(error.send(:handle_message, array)).
|
|
53
|
-
to eq("First message. Second message.")
|
|
54
|
-
end
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
context "when passed a String" do
|
|
58
|
-
it "returns the String untouched" do
|
|
59
|
-
error_str = 'this is an error string'
|
|
60
|
-
|
|
61
|
-
expect(error.send(:handle_message, error_str)).
|
|
62
|
-
to eq(error_str)
|
|
63
|
-
end
|
|
64
|
-
end
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
describe "#response_message" do
|
|
68
|
-
it "returns the message of the parsed_response" do
|
|
69
|
-
expect(error.response_message).to eq(body.string)
|
|
70
|
-
end
|
|
71
|
-
end
|
|
72
|
-
end
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
describe Gitlab::FileResponse do
|
|
4
|
-
before do
|
|
5
|
-
@file_response = Gitlab::FileResponse.new StringIO.new("", 'rb+')
|
|
6
|
-
end
|
|
7
|
-
|
|
8
|
-
context '.empty?' do
|
|
9
|
-
it "returns false" do
|
|
10
|
-
expect(@file_response.empty?).to be false
|
|
11
|
-
end
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
context '.to_hash' do
|
|
15
|
-
it "has `filename` key and `data` key" do
|
|
16
|
-
h = @file_response.to_hash
|
|
17
|
-
expect(h.key?(:filename)).to be_truthy
|
|
18
|
-
expect(h.key?(:data)).to be_truthy
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
context '.parse_headers!' do
|
|
23
|
-
it "parses headers" do
|
|
24
|
-
@file_response.parse_headers!('Content-Disposition' => 'attachment; filename=artifacts.zip')
|
|
25
|
-
expect(@file_response.filename).to eq "artifacts.zip"
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
it "handles quoted filenames" do
|
|
29
|
-
@file_response.parse_headers!('Content-Disposition' => 'attachment; filename="artifacts.zip"')
|
|
30
|
-
expect(@file_response.filename).to eq "artifacts.zip"
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
end
|
data/spec/gitlab/help_spec.rb
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
describe Gitlab::Help do
|
|
4
|
-
describe ".ri_cmd" do
|
|
5
|
-
context "ri command found" do
|
|
6
|
-
it "returns the path to RI" do
|
|
7
|
-
allow(Gitlab::Help).to receive(:`).with(/which ri/).and_return('/usr/bin/ri')
|
|
8
|
-
expect(Gitlab::Help.ri_cmd).to eq('/usr/bin/ri')
|
|
9
|
-
end
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
context "ri command NOT found" do
|
|
13
|
-
it "raises RuntimeError" do
|
|
14
|
-
allow(Gitlab::Help).to receive(:`).with(/which ri/).and_return('')
|
|
15
|
-
expect { Gitlab::Help.ri_cmd }.to raise_error RuntimeError
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
describe ".change_help_output!" do
|
|
21
|
-
before do
|
|
22
|
-
@cmd = "create_branch"
|
|
23
|
-
@help_output = "Gitlab.#{@cmd}(4, 'new-branch', 'master')"
|
|
24
|
-
@help_output_with_options = "Gitlab.groups({ per_page: 3 })"
|
|
25
|
-
end
|
|
26
|
-
it "returns a String of modified output" do
|
|
27
|
-
Gitlab::Help.change_help_output! @cmd, @help_output
|
|
28
|
-
expect(@help_output).to eq("Gitlab.create_branch 4 'new-branch' 'master'")
|
|
29
|
-
end
|
|
30
|
-
it "formats options hash and return a String of modified output" do
|
|
31
|
-
Gitlab::Help.change_help_output! 'groups', @help_output_with_options
|
|
32
|
-
expect(@help_output_with_options).to eq("Gitlab.groups \"{ per_page: 3 }\"")
|
|
33
|
-
end
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
describe ".namespace" do
|
|
37
|
-
before do
|
|
38
|
-
@cmd = 'create_tag'
|
|
39
|
-
@namespace = Gitlab::Help.namespace @cmd
|
|
40
|
-
end
|
|
41
|
-
it "returns the full namespace for a command" do
|
|
42
|
-
expect(@namespace).to be_a String
|
|
43
|
-
expect(@namespace).to eq("Gitlab::Client::Tags.#{@cmd}")
|
|
44
|
-
end
|
|
45
|
-
end
|
|
46
|
-
end
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
describe Gitlab::ObjectifiedHash do
|
|
4
|
-
before do
|
|
5
|
-
@hash = { a: 1, b: 2, 'string' => 'string', symbol: :symbol }
|
|
6
|
-
@oh = Gitlab::ObjectifiedHash.new @hash
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
it "objectifies a hash" do
|
|
10
|
-
expect(@oh.a).to eq(@hash[:a])
|
|
11
|
-
expect(@oh.b).to eq(@hash[:b])
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
describe "#to_hash" do
|
|
15
|
-
it "returns an original hash" do
|
|
16
|
-
expect(@oh.to_hash).to eq(@hash)
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
it "has an alias #to_h" do
|
|
20
|
-
expect(@oh.respond_to?(:to_h)).to be_truthy
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
describe "#inspect" do
|
|
25
|
-
it "returns a formatted string" do
|
|
26
|
-
pretty_string = "#<#{@oh.class.name}:#{@oh.object_id} {hash: #{@hash}}"
|
|
27
|
-
expect(@oh.inspect).to eq(pretty_string)
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
describe "#respond_to" do
|
|
32
|
-
it "returns true for methods this object responds to through method_missing as sym" do
|
|
33
|
-
expect(@oh.respond_to?(:a)).to be_truthy
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
it "returns true for methods this object responds to through method_missing as string" do
|
|
37
|
-
expect(@oh.respond_to?('string')).to be_truthy
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
it "does not care if you use a string or symbol to reference a method" do
|
|
41
|
-
expect(@oh.respond_to?(:string)).to be_truthy
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
it "does not care if you use a string or symbol to reference a method" do
|
|
45
|
-
expect(@oh.respond_to?('symbol')).to be_truthy
|
|
46
|
-
end
|
|
47
|
-
end
|
|
48
|
-
end
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
describe Gitlab::PageLinks do
|
|
4
|
-
before do
|
|
5
|
-
@page_links = Gitlab::PageLinks.new('Link' => "<http://example.com/api/v3/projects?page=1&per_page=5>; rel=\"first\", <http://example.com/api/v3/projects?page=20&per_page=5>; rel=\"last\", <http://example.com/api/v3/projects?page=7&per_page=5>; rel=\"prev\", <http://example.com/api/v3/projects?page=9&per_page=5>; rel=\"next\"")
|
|
6
|
-
end
|
|
7
|
-
|
|
8
|
-
context '.extract_links' do
|
|
9
|
-
it 'extracts link header appropriately' do
|
|
10
|
-
expect(@page_links.last).to eql 'http://example.com/api/v3/projects?page=20&per_page=5'
|
|
11
|
-
expect(@page_links.first).to eql 'http://example.com/api/v3/projects?page=1&per_page=5'
|
|
12
|
-
expect(@page_links.next).to eql 'http://example.com/api/v3/projects?page=9&per_page=5'
|
|
13
|
-
expect(@page_links.prev).to eql 'http://example.com/api/v3/projects?page=7&per_page=5'
|
|
14
|
-
end
|
|
15
|
-
end
|
|
16
|
-
end
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
describe Gitlab::PaginatedResponse do
|
|
4
|
-
before do
|
|
5
|
-
array = [1, 2, 3, 4]
|
|
6
|
-
@paginated_response = Gitlab::PaginatedResponse.new array
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
it "responds to *_page and has_*_page methods" do
|
|
10
|
-
expect(@paginated_response).to respond_to :first_page
|
|
11
|
-
expect(@paginated_response).to respond_to :last_page
|
|
12
|
-
expect(@paginated_response).to respond_to :next_page
|
|
13
|
-
expect(@paginated_response).to respond_to :prev_page
|
|
14
|
-
expect(@paginated_response).to respond_to :has_first_page?
|
|
15
|
-
expect(@paginated_response).to respond_to :has_last_page?
|
|
16
|
-
expect(@paginated_response).to respond_to :has_next_page?
|
|
17
|
-
expect(@paginated_response).to respond_to :has_prev_page?
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
context '.parse_headers!' do
|
|
21
|
-
it "parses headers" do
|
|
22
|
-
@paginated_response.parse_headers!('Link' => "<http://example.com/api/v3/projects?page=1&per_page=5>; rel=\"first\", <http://example.com/api/v3/projects?page=20&per_page=5>; rel=\"last\"")
|
|
23
|
-
client = @paginated_response.client = double('client')
|
|
24
|
-
first_page_response = double('first_page_response')
|
|
25
|
-
last_page_response = double('last_page_response')
|
|
26
|
-
allow(client).to receive(:endpoint).and_return("http://example.com/api/v3")
|
|
27
|
-
allow(client).to receive(:get).with("/projects?page=1&per_page=5").and_return(first_page_response)
|
|
28
|
-
allow(client).to receive(:get).with("/projects?page=20&per_page=5").and_return(last_page_response)
|
|
29
|
-
expect(@paginated_response.has_first_page?).to be true
|
|
30
|
-
expect(@paginated_response.has_last_page?).to be true
|
|
31
|
-
expect(@paginated_response.has_next_page?).to be false
|
|
32
|
-
expect(@paginated_response.has_prev_page?).to be false
|
|
33
|
-
expect(@paginated_response.first_page).to be first_page_response
|
|
34
|
-
expect(@paginated_response.last_page).to be last_page_response
|
|
35
|
-
expect(@paginated_response.next_page).to be_nil
|
|
36
|
-
expect(@paginated_response.prev_page).to be_nil
|
|
37
|
-
end
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
context '.each_page' do
|
|
41
|
-
it "iterates pages" do
|
|
42
|
-
next_page = double('next_page')
|
|
43
|
-
allow(@paginated_response).to receive(:has_next_page?).and_return(true)
|
|
44
|
-
allow(@paginated_response).to receive(:next_page).and_return(next_page)
|
|
45
|
-
allow(next_page).to receive(:has_next_page?).and_return(false)
|
|
46
|
-
expect { |b| @paginated_response.each_page(&b) }.to yield_successive_args(@paginated_response, next_page)
|
|
47
|
-
end
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
context '.auto_paginate' do
|
|
51
|
-
it "returns an array if block is not given" do
|
|
52
|
-
next_page = double('next_page')
|
|
53
|
-
allow(@paginated_response).to receive(:has_next_page?).and_return(true)
|
|
54
|
-
allow(@paginated_response).to receive(:next_page).and_return(next_page)
|
|
55
|
-
allow(next_page).to receive(:has_next_page?).and_return(false)
|
|
56
|
-
allow(next_page).to receive(:to_ary).and_return([5, 6, 7, 8])
|
|
57
|
-
expect(@paginated_response.auto_paginate).to contain_exactly(1, 2, 3, 4, 5, 6, 7, 8)
|
|
58
|
-
end
|
|
59
|
-
end
|
|
60
|
-
end
|
data/spec/gitlab/request_spec.rb
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
describe Gitlab::Request do
|
|
4
|
-
it { is_expected.to respond_to :get }
|
|
5
|
-
it { is_expected.to respond_to :post }
|
|
6
|
-
it { is_expected.to respond_to :put }
|
|
7
|
-
it { is_expected.to respond_to :delete }
|
|
8
|
-
before do
|
|
9
|
-
@request = Gitlab::Request.new
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
describe ".default_options" do
|
|
13
|
-
it "has 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 "returns 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 "#request_defaults" do
|
|
35
|
-
context "when endpoint is not set" do
|
|
36
|
-
it "raises Error::MissingCredentials" do
|
|
37
|
-
@request.endpoint = nil
|
|
38
|
-
expect do
|
|
39
|
-
@request.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.com'
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
it "sets default_params" do
|
|
50
|
-
@request.request_defaults('sudoer')
|
|
51
|
-
expect(Gitlab::Request.default_params).to eq(sudo: 'sudoer')
|
|
52
|
-
end
|
|
53
|
-
end
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
describe "#authorization_header" do
|
|
57
|
-
it "raises MissingCredentials when auth_token and private_token are not set" do
|
|
58
|
-
expect do
|
|
59
|
-
@request.send(:authorization_header, {})
|
|
60
|
-
end.to raise_error(Gitlab::Error::MissingCredentials)
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
it "sets the correct header when given a private_token" do
|
|
64
|
-
@request.private_token = 'ys9BtunN3rDKbaJCYXaN'
|
|
65
|
-
expect(@request.send(:authorization_header, {})).to eq("PRIVATE-TOKEN" => 'ys9BtunN3rDKbaJCYXaN')
|
|
66
|
-
end
|
|
67
|
-
|
|
68
|
-
it "sets the correct header when setting an auth_token via the private_token config option" do
|
|
69
|
-
@request.private_token = '3225e2804d31fea13fc41fc83bffef00cfaedc463118646b154acc6f94747603'
|
|
70
|
-
expect(@request.send(: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 "raises RuntimeError" 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 "returns a Gitlab::Shell::History instance" do
|
|
22
|
-
expect(@history).to be_a Gitlab::Shell::History
|
|
23
|
-
end
|
|
24
|
-
it "responds to :save" do
|
|
25
|
-
expect(@history).to respond_to :save
|
|
26
|
-
end
|
|
27
|
-
it "responds to :load" do
|
|
28
|
-
expect(@history).to respond_to :load
|
|
29
|
-
end
|
|
30
|
-
it "responds to :<<" do
|
|
31
|
-
expect(@history).to respond_to :<<
|
|
32
|
-
end
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
describe ".setup" do
|
|
36
|
-
it "sets 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 "sets 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 "returns a Proc object" do
|
|
52
|
-
expect(@comp).to be_a Proc
|
|
53
|
-
end
|
|
54
|
-
context "called with an argument" do
|
|
55
|
-
it "returns 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_access_requests group_member group_members group_milestone group_milestone_issues group_milestone_merge_requests group_milestones group_projects group_search group_subgroups group_variable group_variables groups))
|
|
59
|
-
end
|
|
60
|
-
end
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
describe ".parse_input" do
|
|
64
|
-
context "with arguments" do
|
|
65
|
-
it "sets 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 'sets 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
|