Commit 1ba0b0c7 authored by Arturo Herrero's avatar Arturo Herrero

Merge branch 'vij-namespace-limits' into 'master'

Fix locked nested projects after storage purchase

See merge request gitlab-org/gitlab!53249
parents 19ca6e9e 223c07a7
...@@ -101,7 +101,9 @@ module EE ...@@ -101,7 +101,9 @@ module EE
end end
def namespace_limit def namespace_limit
super.presence || build_namespace_limit limit = has_parent? ? root_ancestor.namespace_limit : super
limit.presence || build_namespace_limit
end end
class_methods do 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 ...@@ -1602,12 +1602,49 @@ RSpec.describe Namespace do
end end
end end
describe 'ensure namespace limit' do describe '#namespace_limit' do
it 'has namespace limit upon namespace initialization' do let(:namespace) { create(:namespace, parent: parent) }
namespace = build(:namespace)
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 context 'with a namespace limit' do
expect(namespace.namespace_limit).not_to be_persisted 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
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