diff options
author | Douwe Maan <douwe@gitlab.com> | 2018-03-12 22:56:45 +0000 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2018-03-12 22:56:45 +0000 |
commit | 51f91537640d71262c2fa5070dfb7f8178d1decd (patch) | |
tree | db25990e436c0c016ad577040ddc1a73bf7dfad2 /spec/helpers | |
parent | 198495adf4736b48b93473c996e55ee9b73a2739 (diff) | |
parent | afe2c15e6bf1005e5bd1d213d3548a1a17a11137 (diff) | |
download | gitlab-ce-51f91537640d71262c2fa5070dfb7f8178d1decd.tar.gz |
Merge branch 'rd-fix-github-url-when-listing-repositories-at-importing' into 'master'
Fix provider server URL used when listing repos to import
See merge request gitlab-org/gitlab-ce!17692
Diffstat (limited to 'spec/helpers')
-rw-r--r-- | spec/helpers/import_helper_spec.rb | 33 |
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 |