summaryrefslogtreecommitdiff
path: root/spec/helpers
diff options
context:
space:
mode:
authorRubén Dávila <ruben@gitlab.com>2018-03-12 16:01:43 -0500
committerRubén Dávila <ruben@gitlab.com>2018-03-12 16:01:43 -0500
commitafe2c15e6bf1005e5bd1d213d3548a1a17a11137 (patch)
treea31f89b2ab3dbec92ef11fb2cf106d190ba68668 /spec/helpers
parentafd2d381119c3778140c3dd63c7ef24ecdb4c62e (diff)
downloadgitlab-ce-afe2c15e6bf1005e5bd1d213d3548a1a17a11137.tar.gz
Fix provider server URL used when listing repos to importrd-fix-github-url-when-listing-repositories-at-importing
Also use Gitlab::Auth::OAuth::Provider.config_for to access OmniAuth config
Diffstat (limited to 'spec/helpers')
-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