Commit 223c07a7 authored by Vijay Hawoldar's avatar Vijay Hawoldar Committed by Arturo Herrero

Use ancestor namespace_limit for checking size

When checking for repo size limits, we check
the ancestor namespace for namespace_limits
parent 9662c35c
......@@ -101,7 +101,9 @@ module EE
end
def namespace_limit
super.presence || build_namespace_limit
limit = has_parent? ? root_ancestor.namespace_limit : super
limit.presence || build_namespace_limit
end
class_methods do
......
---
title: Fix sub-group projects being locked after storage purchase
merge_request: 53249
author:
type: fixed
......@@ -1602,12 +1602,49 @@ RSpec.describe Namespace do
end
end
describe 'ensure namespace limit' do
it 'has namespace limit upon namespace initialization' do
namespace = build(:namespace)
describe '#namespace_limit' do
let(:namespace) { create(:namespace, parent: parent) }
subject(:namespace_limit) { namespace.namespace_limit }
context 'when there is a parent namespace' do
let_it_be(:parent) { create(:namespace) }
context 'with a namespace limit' do
it 'returns the parent namespace limit' do
parent_limit = create(:namespace_limit, namespace: parent)
expect(namespace_limit).to eq parent_limit
expect(namespace_limit).to be_persisted
end
end
context 'with no namespace limit' do
it 'builds namespace limit' do
expect(namespace_limit).to be_present
expect(namespace_limit).not_to be_persisted
end
end
end
context 'when there is no parent ancestor' do
let(:parent) { nil }
expect(namespace.namespace_limit).to be_present
expect(namespace.namespace_limit).not_to be_persisted
context 'with a namespace limit' do
it 'returns the namespace limit' do
limit = create(:namespace_limit, namespace: namespace)
expect(namespace_limit).to be_persisted
expect(namespace_limit).to eq limit
end
end
context 'with no namespace limit' do
it 'builds namespace limit' do
expect(namespace_limit).to be_present
expect(namespace_limit).not_to be_persisted
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