Commit 74c88733 authored by Corinna Wiesner's avatar Corinna Wiesner Committed by Michael Kozono

Make messages for reaching storage limit clearer

Some messages shown in the terminal were phrased unclear on how to
reduce storage capacity. This change will make those messages clearer.
parent cf5e878a
......@@ -39,6 +39,10 @@ module Namespaces
end
end
def base_message
s_("NamespaceStorageSize|push to your repository, create pipelines, create issues or add comments. To learn more about reducing storage capacity please visit our docs.")
end
def formatted(number)
number_to_human_size(number, delimiter: ',', precision: 2)
end
......
......@@ -23,12 +23,13 @@ module EE
[size, 0].max
end
private
override :additional_repo_storage_available?
def additional_repo_storage_available?
!!namespace&.additional_repo_storage_by_namespace_enabled?
end
private
def total_repository_size_excess
namespace&.total_repository_size_excess.to_i
end
......
......@@ -193,4 +193,20 @@ RSpec.describe Gitlab::RepositorySizeChecker do
include_examples 'checker size exceeded'
end
end
describe '#additional_repo_storage_available?' do
context 'when additional_repo_storage_by_namespace_enabled is true' do
it 'returns true' do
expect(subject.additional_repo_storage_available?).to eq(true)
end
end
context 'when additional_repo_storage_by_namespace_enabled is false' do
let(:additional_repo_storage_by_namespace_enabled) { false }
it 'returns false' do
expect(subject.additional_repo_storage_available?).to eq(false)
end
end
end
end
......@@ -46,6 +46,10 @@ module Gitlab
@error_message_object ||= ::Gitlab::RepositorySizeErrorMessage.new(self)
end
def additional_repo_storage_available?
false
end
private
attr_reader :namespace
......
......@@ -4,7 +4,7 @@ module Gitlab
class RepositorySizeErrorMessage
include ActiveSupport::NumberHelper
delegate :current_size, :limit, :exceeded_size, to: :@checker
delegate :current_size, :limit, :exceeded_size, :additional_repo_storage_available?, to: :@checker
# @param checher [RepositorySizeChecker]
def initialize(checker)
......@@ -24,7 +24,11 @@ module Gitlab
end
def new_changes_error
"Your push to this repository would cause it to exceed the size limit of #{formatted(limit)} so it has been rejected. #{more_info_message}"
if additional_repo_storage_available?
"Your push to this repository has been rejected because it would exceed storage limits. Please contact your GitLab administrator for more information."
else
"Your push to this repository would cause it to exceed the size limit of #{formatted(limit)} so it has been rejected. #{more_info_message}"
end
end
def more_info_message
......
......@@ -17900,6 +17900,9 @@ msgid_plural "NamespaceStorageSize|You have reached the free storage limit of %{
msgstr[0] ""
msgstr[1] ""
msgid "NamespaceStorageSize|push to your repository, create pipelines, create issues or add comments. To learn more about reducing storage capacity please visit our docs."
msgstr ""
msgid "NamespaceStorageSize|push to your repository, create pipelines, create issues or add comments. To reduce storage capacity, delete unused repositories, artifacts, wikis, issues, and pipelines."
msgstr ""
......
......@@ -53,4 +53,10 @@ RSpec.describe Gitlab::RepositorySizeChecker do
describe '#exceeded_size' do
include_examples 'checker size exceeded'
end
describe '#additional_repo_storage_available?' do
it 'returns false' do
expect(subject.additional_repo_storage_available?).to eq(false)
end
end
end
......@@ -53,8 +53,18 @@ RSpec.describe Gitlab::RepositorySizeErrorMessage do
end
describe '#new_changes_error' do
it 'returns the correct message' do
expect(message.new_changes_error).to eq("Your push to this repository would cause it to exceed the size limit of 10 MB so it has been rejected. #{message.more_info_message}")
context 'when additional repo storage is available' do
it 'returns the correct message' do
allow(checker).to receive(:additional_repo_storage_available?).and_return(true)
expect(message.new_changes_error).to eq('Your push to this repository has been rejected because it would exceed storage limits. Please contact your GitLab administrator for more information.')
end
end
context 'when no additional repo storage is available' do
it 'returns the correct message' do
expect(message.new_changes_error).to eq("Your push to this repository would cause it to exceed the size limit of 10 MB so it has been rejected. #{message.more_info_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