Commit 9172d320 authored by James Lopez's avatar James Lopez

refactor git access spec, update docs

parent 903aab5f
[//]: # (Please update EE::GitLab::GeoGitAccess::GEO_SERVER_DOCS_URL if this file is moved)
# Using a Geo Server # Using a Geo Server
After you set up the [database replication and configure the GitLab Geo nodes][req], After you set up the [database replication and configure the GitLab Geo nodes][req],
......
module EE module EE
module Gitlab module Gitlab
module GitAccess module GitAccess
GEO_SERVER_DOCS_URL = 'https://docs.gitlab.com/ee/gitlab-geo/using_a_geo_server.html'.freeze prepend GeoGitAccess
def check(cmd, changes) def check(cmd, changes)
raise NotImplementedError.new unless defined?(super) raise NotImplementedError.new unless defined?(super)
...@@ -65,17 +65,6 @@ module EE ...@@ -65,17 +65,6 @@ module EE
def geo? def geo?
geo_node_key? || actor == :geo geo_node_key? || actor == :geo
end end
def push_to_read_only_message
message = super
if ::Gitlab::Geo.primary_node
primary_url = ActionController::Base.helpers.link_to('primary node', ::Gitlab::Geo.primary_node.url)
message += " Please use the Primary node URL: #{primary_url.html_safe}. Documentation: #{GEO_SERVER_DOCS_URL}"
end
message
end
end end
end end
end end
...@@ -10,7 +10,7 @@ describe Gitlab::GitAccess do ...@@ -10,7 +10,7 @@ describe Gitlab::GitAccess do
let(:redirected_path) { nil } let(:redirected_path) { nil }
let(:access) { described_class.new(actor, project, protocol, authentication_abilities: authentication_abilities, redirected_path: redirected_path) } let(:access) { described_class.new(actor, project, protocol, authentication_abilities: authentication_abilities, redirected_path: redirected_path) }
let(:push_access_check) { access.check('git-receive-pack', '_any') } subject { access.check('git-receive-pack', '_any') }
context "when in a read-only GitLab instance" do context "when in a read-only GitLab instance" do
before do before do
...@@ -21,7 +21,7 @@ describe Gitlab::GitAccess do ...@@ -21,7 +21,7 @@ describe Gitlab::GitAccess do
it 'denies push access' do it 'denies push access' do
project.add_master(user) project.add_master(user)
expect { push_access_check }.to raise_unauthorized("You can't push code to a read-only GitLab instance.") expect { subject }.to raise_unauthorized("You can't push code to a read-only GitLab instance.")
end end
it 'denies push access with primary present' do it 'denies push access with primary present' do
...@@ -33,7 +33,7 @@ describe Gitlab::GitAccess do ...@@ -33,7 +33,7 @@ describe Gitlab::GitAccess do
project.add_master(user) project.add_master(user)
expect { push_access_check }.to raise_unauthorized(error_message) expect { subject }.to raise_unauthorized(error_message)
end 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