Commit 070792a7 authored by Stan Hu's avatar Stan Hu

Add spec for Geo routing improvements

parent 9fcb63db
module EE
module GitlabRoutingHelper
include ProjectsHelper
include ApplicationSettingsHelper
def geo_primary_web_url(project)
File.join(::Gitlab::Geo.primary_node.url, ::Gitlab::Routing.url_helpers.namespace_project_path(project.namespace, project))
end
......@@ -14,10 +17,10 @@ module EE
def geo_primary_default_url_to_repo(project)
case default_clone_protocol
when 'http'
geo_primary_http_url_to_repo(project)
when 'ssh'
geo_primary_ssh_url_to_repo(project)
else
geo_primary_http_url_to_repo(project)
end
end
end
......
require 'spec_helper'
describe EE::GitlabRoutingHelper do
include ProjectsHelper
include ApplicationSettingsHelper
let!(:primary_node) { create(:geo_node, :primary) }
let(:project) { build_stubbed(:empty_project) }
describe '#geo_primary_default_url_to_repo' do
it 'returns an HTTP URL' do
allow(helper).to receive(:default_clone_protocol).and_return('http')
result = helper.geo_primary_default_url_to_repo(project)
expect(result).to start_with('http://')
expect(result).to eq(helper.geo_primary_http_url_to_repo(project))
end
it 'returns an HTTPS URL' do
primary_node.update_attribute(:schema, 'https')
allow(helper).to receive(:default_clone_protocol).and_return('https')
result = helper.geo_primary_default_url_to_repo(project)
expect(result).to start_with('https://')
expect(result).to eq(helper.geo_primary_http_url_to_repo(project))
end
it 'returns an SSH URL' do
allow(helper).to receive(:default_clone_protocol).and_return('ssh')
result = helper.geo_primary_default_url_to_repo(project)
expect(result).to start_with('git@')
expect(result).to eq(helper.geo_primary_ssh_url_to_repo(project))
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment