Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-04-07 18:09:30 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-04-07 18:09:30 +0300
commitc6b3ec3f56fa32a0e0ed3de0d0878d25f1adaddf (patch)
tree967afee9a510ff9dd503ebd83706dc760ec2e3ed /spec/lib/gitlab/repository_url_builder_spec.rb
parent903ccf7c93eb9490c76857bffe744249cc07de09 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/lib/gitlab/repository_url_builder_spec.rb')
-rw-r--r--spec/lib/gitlab/repository_url_builder_spec.rb56
1 files changed, 56 insertions, 0 deletions
diff --git a/spec/lib/gitlab/repository_url_builder_spec.rb b/spec/lib/gitlab/repository_url_builder_spec.rb
new file mode 100644
index 00000000000..3d8870ecb53
--- /dev/null
+++ b/spec/lib/gitlab/repository_url_builder_spec.rb
@@ -0,0 +1,56 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+describe Gitlab::RepositoryUrlBuilder do
+ describe '.build' do
+ using RSpec::Parameterized::TableSyntax
+
+ where(:factory, :path_generator) do
+ :project | ->(project) { project.full_path }
+ :project_snippet | ->(snippet) { "#{snippet.project.full_path}/snippets/#{snippet.id}" }
+ :project_wiki | ->(wiki) { "#{wiki.project.full_path}.wiki" }
+
+ :personal_snippet | ->(snippet) { "snippets/#{snippet.id}" }
+ end
+
+ with_them do
+ let(:container) { build_stubbed(factory) }
+ let(:repository) { container.repository }
+ let(:path) { path_generator.call(container) }
+ let(:url) { subject.build(repository.full_path, protocol: protocol) }
+
+ context 'when passing SSH protocol' do
+ let(:protocol) { :ssh }
+
+ it 'returns the SSH URL to the repository' do
+ expect(url).to eq("#{Gitlab.config.gitlab_shell.ssh_path_prefix}#{path}.git")
+ end
+ end
+
+ context 'when passing HTTP protocol' do
+ let(:protocol) { :http }
+
+ it 'returns the HTTP URL to the repo without a username' do
+ expect(url).to eq("#{Gitlab.config.gitlab.url}/#{path}.git")
+ expect(url).not_to include('@')
+ end
+
+ it 'includes the custom HTTP clone root if set' do
+ clone_root = 'https://git.example.com:51234/mygitlab'
+ stub_application_setting(custom_http_clone_url_root: clone_root)
+
+ expect(url).to eq("#{clone_root}/#{path}.git")
+ end
+ end
+
+ context 'when passing an unsupported protocol' do
+ let(:protocol) { :ftp }
+
+ it 'raises an exception' do
+ expect { url }.to raise_error(NotImplementedError)
+ end
+ end
+ end
+ end
+end