Commit 915bd35e authored by James Lopez's avatar James Lopez

refactor code to use original protocol

parent 1f9f1706
...@@ -10,14 +10,22 @@ module EE ...@@ -10,14 +10,22 @@ module EE
def push_to_read_only_message def push_to_read_only_message
message = super message = super
if ::Gitlab::Geo.primary_node if ::Gitlab::Geo.secondary_with_primary?
clone_url = geo_primary_default_url_to_repo(project_or_wiki) message += " Please use the Primary node URL: #{geo_primary_url_to_repo}. Documentation: #{GEO_SERVER_DOCS_URL}"
message += " Please use the Primary node URL: #{clone_url}. Documentation: #{GEO_SERVER_DOCS_URL}"
end end
message message
end end
def geo_primary_url_to_repo
case protocol
when 'ssh'
geo_primary_ssh_url_to_repo(project_or_wiki)
else
geo_primary_http_url_to_repo(project_or_wiki)
end
end
def current_user def current_user
user user
end end
......
...@@ -5,7 +5,7 @@ describe Gitlab::GitAccess do ...@@ -5,7 +5,7 @@ describe Gitlab::GitAccess do
let(:actor) { user } let(:actor) { user }
let(:project) { create(:project, :repository) } let(:project) { create(:project, :repository) }
let(:protocol) { 'ssh' } let(:protocol) { 'web' }
let(:authentication_abilities) { %i[read_project download_code push_code] } let(:authentication_abilities) { %i[read_project download_code push_code] }
let(:redirected_path) { nil } let(:redirected_path) { nil }
...@@ -30,6 +30,7 @@ describe Gitlab::GitAccess do ...@@ -30,6 +30,7 @@ describe Gitlab::GitAccess do
primary_node = create(:geo_node, :primary, url: 'https://localhost:3000/gitlab') primary_node = create(:geo_node, :primary, url: 'https://localhost:3000/gitlab')
allow(Gitlab::Geo).to receive(:primary).and_return(primary_node) allow(Gitlab::Geo).to receive(:primary).and_return(primary_node)
allow(Gitlab::Geo).to receive(:secondary_with_primary?).and_return(true)
project.add_master(user) project.add_master(user)
......
...@@ -34,6 +34,7 @@ describe Gitlab::GitAccessWiki do ...@@ -34,6 +34,7 @@ describe Gitlab::GitAccessWiki do
primary_node = create(:geo_node, :primary, url: 'https://localhost:3000/gitlab') primary_node = create(:geo_node, :primary, url: 'https://localhost:3000/gitlab')
allow(Gitlab::Geo).to receive(:primary).and_return(primary_node) allow(Gitlab::Geo).to receive(:primary).and_return(primary_node)
allow(Gitlab::Geo).to receive(:secondary_with_primary?).and_return(true)
project.add_master(user) project.add_master(user)
......
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