summaryrefslogtreecommitdiff
path: root/spec/helpers/import_helper_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/helpers/import_helper_spec.rb')
-rw-r--r--spec/helpers/import_helper_spec.rb33
1 files changed, 28 insertions, 5 deletions
diff --git a/spec/helpers/import_helper_spec.rb b/spec/helpers/import_helper_spec.rb
index 9afff47f4e9..57d843c1be2 100644
--- a/spec/helpers/import_helper_spec.rb
+++ b/spec/helpers/import_helper_spec.rb
@@ -27,25 +27,48 @@ describe ImportHelper do
describe '#provider_project_link' do
context 'when provider is "github"' do
+ let(:github_server_url) { nil }
+
+ before do
+ setting = Settingslogic.new('name' => 'github')
+ setting['url'] = github_server_url if github_server_url
+
+ allow(Gitlab.config.omniauth).to receive(:providers).and_return([setting])
+ end
+
context 'when provider does not specify a custom URL' do
it 'uses default GitHub URL' do
- allow(Gitlab.config.omniauth).to receive(:providers)
- .and_return([Settingslogic.new('name' => 'github')])
-
expect(helper.provider_project_link('github', 'octocat/Hello-World'))
.to include('href="https://github.com/octocat/Hello-World"')
end
end
context 'when provider specify a custom URL' do
+ let(:github_server_url) { 'https://github.company.com' }
+
it 'uses custom URL' do
- allow(Gitlab.config.omniauth).to receive(:providers)
- .and_return([Settingslogic.new('name' => 'github', 'url' => 'https://github.company.com')])
+ expect(helper.provider_project_link('github', 'octocat/Hello-World'))
+ .to include('href="https://github.company.com/octocat/Hello-World"')
+ end
+ end
+
+ context "when custom URL contains a '/' char at the end" do
+ let(:github_server_url) { 'https://github.company.com/' }
+ it "doesn't render double slash" do
expect(helper.provider_project_link('github', 'octocat/Hello-World'))
.to include('href="https://github.company.com/octocat/Hello-World"')
end
end
+
+ context 'when provider is missing' do
+ it 'uses the default URL' do
+ allow(Gitlab.config.omniauth).to receive(:providers).and_return([])
+
+ expect(helper.provider_project_link('github', 'octocat/Hello-World'))
+ .to include('href="https://github.com/octocat/Hello-World"')
+ end
+ end
end
context 'when provider is "gitea"' do