Commit b4a5556c authored by Alper Akgun's avatar Alper Akgun

Merge branch '267971_fix_loading_of_ee_class' into 'master'

Fix loading of EE::Gitlab::RepositorySizeChecker

See merge request gitlab-org/gitlab!45250
parents 49e24165 39210b85
# frozen_string_literal: true
module EE
module Gitlab
module RepositorySizeChecker
extend ActiveSupport::Concern
extend ::Gitlab::Utils::Override
override :above_size_limit?
def above_size_limit?
return false unless enabled?
return false if additional_repo_storage_available? && total_repository_size_excess <= additional_purchased_storage
super
end
override :exceeded_size
# @param change_size [int] in bytes
def exceeded_size(change_size = 0)
exceeded_size = super
exceeded_size -= remaining_additional_purchased_storage if additional_repo_storage_available?
exceeded_size
end
private
def additional_repo_storage_available?
return false unless ::Gitlab::CurrentSettings.automatic_purchased_storage_allocation?
::Feature.enabled?(:additional_repo_storage_by_namespace)
end
def remaining_additional_purchased_storage
additional_purchased_storage - total_repository_size_excess
end
end
end
end
# frozen_string_literal: true
module Gitlab
module RepositorySizeChecker
extend ActiveSupport::Concern
extend ::Gitlab::Utils::Override
override :above_size_limit?
def above_size_limit?
return false unless enabled?
return false if additional_repo_storage_available? && total_repository_size_excess <= additional_purchased_storage
super
end
override :exceeded_size
# @param change_size [int] in bytes
def exceeded_size(change_size = 0)
exceeded_size = super
exceeded_size -= remaining_additional_purchased_storage if additional_repo_storage_available?
exceeded_size
end
private
def additional_repo_storage_available?
return false unless Gitlab::CurrentSettings.automatic_purchased_storage_allocation?
Feature.enabled?(:additional_repo_storage_by_namespace)
end
def remaining_additional_purchased_storage
additional_purchased_storage - total_repository_size_excess
end
end
end
......@@ -42,7 +42,9 @@ module Gitlab
end
def error_message
@error_message_object ||= Gitlab::RepositorySizeErrorMessage.new(self)
@error_message_object ||= ::Gitlab::RepositorySizeErrorMessage.new(self)
end
end
end
Gitlab::RepositorySizeChecker.prepend_if_ee('EE::Gitlab::RepositorySizeChecker')
......@@ -56,7 +56,9 @@ RSpec.describe Snippets::RepositoryValidationService do
end
it 'returns error when the repository size is over the limit' do
expect_any_instance_of(Gitlab::RepositorySizeChecker).to receive(:above_size_limit?).and_return(true)
expect_next_instance_of(Gitlab::RepositorySizeChecker) do |checker|
expect(checker).to receive(:above_size_limit?).and_return(true)
end
expect(subject).to be_error
expect(subject.message).to match /Repository size is above the limit/
......
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