Commit e44821cd authored by Toon Claes's avatar Toon Claes

More readonly to read_only renames

parent 6f3055fa
......@@ -174,8 +174,8 @@ module Gitlab
ENV['GITLAB_PATH_OUTSIDE_HOOK'] = ENV['PATH']
ENV['GIT_TERMINAL_PROMPT'] = '0'
# Gitlab Readonly middleware support
config.middleware.insert_after ActionDispatch::Flash, 'Gitlab::Middleware::Readonly'
# Gitlab Read-only middleware support
config.middleware.insert_after ActionDispatch::Flash, 'Gitlab::Middleware::ReadOnly'
config.generators do |g|
g.factory_girl false
......
......@@ -19,8 +19,8 @@ module Gitlab
command_not_allowed: "The command you're trying to execute is not allowed.",
upload_pack_disabled_over_http: 'Pulling over HTTP is not allowed.',
receive_pack_disabled_over_http: 'Pushing over HTTP is not allowed.',
readonly: 'The repository is temporarily read-only. Please try again later.',
cannot_push_to_readonly: "You can't push code to a read-only GitLab instance."
read_only: 'The repository is temporarily read-only. Please try again later.',
cannot_push_to_read_only: "You can't push code to a read-only GitLab instance."
}.freeze
DOWNLOAD_COMMANDS = %w{ git-upload-pack git-upload-archive }.freeze
......@@ -173,11 +173,11 @@ module Gitlab
# TODO: please clean this up
def check_push_access!(changes)
if project.repository_read_only?
raise UnauthorizedError, ERROR_MESSAGES[:readonly]
raise UnauthorizedError, ERROR_MESSAGES[:read_only]
end
if Gitlab::Database.read_only?
raise UnauthorizedError, ERROR_MESSAGES[:cannot_push_to_readonly]
raise UnauthorizedError, ERROR_MESSAGES[:cannot_push_to_read_only]
end
if deploy_key
......
module Gitlab
module Middleware
class Readonly
class ReadOnly
DISALLOWED_METHODS = %w(POST PATCH PUT DELETE).freeze
APPLICATION_JSON = 'application/json'.freeze
API_VERSIONS = (3..4)
......@@ -14,7 +14,7 @@ module Gitlab
@env = env
if disallowed_request? && Gitlab::Database.read_only?
Rails.logger.debug('GitLab Readonly: preventing possible non readonly operation')
Rails.logger.debug('GitLab ReadOnly: preventing possible non read-only operation')
error_message = 'You cannot do writing operations on a read-only GitLab instance'
if json_request?
......
......@@ -83,7 +83,7 @@ describe EE::User do
expect(subject.reload.remember_created_at).to be_nil
end
it 'does not clear remember_created_at when in a GitLab readonly instance' do
it 'does not clear remember_created_at when in a GitLab read-only instance' do
allow(Gitlab::Database).to receive(:read_only?) { true }
expect { subject.forget_me! }.not_to change(subject, :remember_created_at)
......@@ -99,7 +99,7 @@ describe EE::User do
expect(subject.reload.remember_created_at).not_to be_nil
end
it 'does not update remember_created_at when in a Geo readonly instance' do
it 'does not update remember_created_at when in a Geo read-only instance' do
allow(Gitlab::Database).to receive(:read_only?) { true }
expect { subject.remember_me! }.not_to change(subject, :remember_created_at)
......
......@@ -174,7 +174,7 @@ FactoryGirl.define do
end
end
trait :readonly do
trait :read_only do
repository_read_only true
end
......
......@@ -36,7 +36,7 @@ describe Banzai::Renderer do
is_expected.to eq('field_html')
end
it "skips database caching on a GitLab readonly instance" do
it "skips database caching on a GitLab read-only instance" do
allow(Gitlab::Database).to receive(:read_only?).and_return(true)
expect(object).to receive(:refresh_markdown_cache!)
......
......@@ -943,7 +943,7 @@ describe Gitlab::GitAccess do
end
context 'when the repository is read only' do
let(:project) { create(:project, :repository, :readonly) }
let(:project) { create(:project, :repository, :read_only) }
it 'denies push access' do
project.add_master(user)
......
require 'spec_helper'
describe Gitlab::Middleware::Readonly do
describe Gitlab::Middleware::ReadOnly do
include Rack::Test::Methods
RSpec::Matchers.define :be_a_redirect do
......@@ -38,7 +38,7 @@ describe Gitlab::Middleware::Readonly do
let(:request) { Rack::MockRequest.new(rack_stack) }
context 'normal requests to a readonly Gitlab instance' do
context 'normal requests to a read-only Gitlab instance' do
let(:fake_app) { lambda { |env| [200, { 'Content-Type' => 'text/plain' }, ['OK']] } }
before do
......
......@@ -2928,7 +2928,7 @@ describe Project do
expect(project.migrate_to_hashed_storage!).to be_truthy
end
it 'flags as readonly' do
it 'flags as read-only' do
expect { project.migrate_to_hashed_storage! }.to change { project.repository_read_only }.to(true)
end
......@@ -3055,7 +3055,7 @@ describe Project do
expect(project.migrate_to_hashed_storage!).to be_nil
end
it 'does not flag as readonly' do
it 'does not flag as read-only' do
expect { project.migrate_to_hashed_storage! }.not_to change { project.repository_read_only }
end
end
......
......@@ -20,7 +20,7 @@ describe Projects::HashedStorageMigrationService do
expect(gitlab_shell.exists?(project.repository_storage_path, "#{hashed_storage.disk_path}.wiki.git")).to be_truthy
end
it 'updates project to be hashed and not readonly' do
it 'updates project to be hashed and not read-only' do
service.execute
expect(project.hashed_storage?).to be_truthy
......
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