Commit 5ebc3054 authored by Tyler Amos's avatar Tyler Amos

Do not return negative numbers from exceeded_size

Negative numbers are not needed from this method and may be confusing.
parent b473155e
......@@ -17,9 +17,10 @@ module EE
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
size = super
size -= remaining_additional_purchased_storage if additional_repo_storage_available?
[size, 0].max
end
private
......
......@@ -144,8 +144,8 @@ RSpec.describe Gitlab::RepositorySizeChecker do
context 'when current size + total repository size excess is below the limit (additional purchase storage not used)' do
let(:current_size) { limit - 1 }
it 'returns a negative number' do
expect(subject.exceeded_size).to eq(-1.megabyte)
it 'returns zero' do
expect(subject.exceeded_size).to eq(0)
end
end
......
......@@ -37,7 +37,9 @@ module Gitlab
# @param change_size [int] in bytes
def exceeded_size(change_size = 0)
current_size + change_size - limit
size = current_size + change_size - limit
[size, 0].max
end
def error_message
......
......@@ -21,8 +21,8 @@ RSpec.shared_examples 'checker size exceeded' do
context 'when current size is below the limit' do
let(:current_size) { limit - 1 }
it 'returns a negative number' do
expect(subject.exceeded_size).to eq(-1.megabyte)
it 'returns zero' do
expect(subject.exceeded_size).to eq(0)
end
end
......@@ -67,7 +67,7 @@ RSpec.shared_examples 'checker size exceeded' do
let(:current_size) { limit - 2 }
it 'returns zero' do
expect(subject.exceeded_size(change_size)).to eq(-1.megabyte)
expect(subject.exceeded_size(change_size)).to eq(0)
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