diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-05-19 10:33:21 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-05-19 10:33:21 +0300 |
commit | 36a59d088eca61b834191dacea009677a96c052f (patch) | |
tree | e4f33972dab5d8ef79e3944a9f403035fceea43f /spec/models/namespace_spec.rb | |
parent | a1761f15ec2cae7c7f7bbda39a75494add0dfd6f (diff) |
Add latest changes from gitlab-org/gitlab@15-0-stable-eev15.0.0-rc42
Diffstat (limited to 'spec/models/namespace_spec.rb')
-rw-r--r-- | spec/models/namespace_spec.rb | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/spec/models/namespace_spec.rb b/spec/models/namespace_spec.rb index 09ac15429a5..4373d9a0b24 100644 --- a/spec/models/namespace_spec.rb +++ b/spec/models/namespace_spec.rb @@ -32,6 +32,10 @@ RSpec.describe Namespace do it { is_expected.to have_one :namespace_route } it { is_expected.to have_many :namespace_members } + it do + is_expected.to have_one(:ci_cd_settings).class_name('NamespaceCiCdSetting').inverse_of(:namespace).autosave(true) + end + describe '#children' do let_it_be(:group) { create(:group) } let_it_be(:subgroup) { create(:group, parent: group) } @@ -334,6 +338,15 @@ RSpec.describe Namespace do describe 'delegate' do it { is_expected.to delegate_method(:name).to(:owner).with_prefix.with_arguments(allow_nil: true) } it { is_expected.to delegate_method(:avatar_url).to(:owner).with_arguments(allow_nil: true) } + it do + is_expected.to delegate_method(:prevent_sharing_groups_outside_hierarchy) + .to(:namespace_settings).with_arguments(allow_nil: true) + end + + it do + is_expected.to delegate_method(:prevent_sharing_groups_outside_hierarchy=) + .to(:namespace_settings).with_arguments(allow_nil: true) + end end describe "Respond to" do @@ -2236,4 +2249,40 @@ RSpec.describe Namespace do it_behaves_like 'blocks unsafe serialization' end + + describe '#certificate_based_clusters_enabled?' do + it 'does not call Feature.enabled? twice with request_store', :request_store do + expect(Feature).to receive(:enabled?).once + + namespace.certificate_based_clusters_enabled? + namespace.certificate_based_clusters_enabled? + end + + it 'call Feature.enabled? twice without request_store' do + expect(Feature).to receive(:enabled?).twice + + namespace.certificate_based_clusters_enabled? + namespace.certificate_based_clusters_enabled? + end + + context 'with ff disabled' do + before do + stub_feature_flags(certificate_based_clusters: false) + end + + it 'is truthy' do + expect(namespace.certificate_based_clusters_enabled?).to be_falsy + end + end + + context 'with ff enabled' do + before do + stub_feature_flags(certificate_based_clusters: true) + end + + it 'is truthy' do + expect(namespace.certificate_based_clusters_enabled?).to be_truthy + end + end + end end |