diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-09-15 18:10:36 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-09-15 18:10:36 +0000 |
commit | 99aa31992d4398d35c9df4854f5fb494984a9e0b (patch) | |
tree | c2ca79f7ea8e5daaf8e62b5d523a986331d97647 /spec/models/namespace_spec.rb | |
parent | 229395d3af51cd46a9179f2eba142c027d08b208 (diff) | |
download | gitlab-ce-99aa31992d4398d35c9df4854f5fb494984a9e0b.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/models/namespace_spec.rb')
-rw-r--r-- | spec/models/namespace_spec.rb | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/spec/models/namespace_spec.rb b/spec/models/namespace_spec.rb index 9214618f97b..2e8d22cb9db 100644 --- a/spec/models/namespace_spec.rb +++ b/spec/models/namespace_spec.rb @@ -336,6 +336,26 @@ RSpec.describe Namespace do expect(described_class.without_project_namespaces).to match_array([namespace, namespace1, namespace2, namespace1sub, namespace2sub, user_namespace, project_namespace.parent]) end end + + describe '.with_shared_runners_enabled' do + subject { described_class.with_shared_runners_enabled } + + context 'when shared runners are enabled for namespace' do + let!(:namespace_inheriting_shared_runners) { create(:namespace, shared_runners_enabled: true) } + + it "returns a namespace inheriting shared runners" do + is_expected.to include(namespace_inheriting_shared_runners) + end + end + + context 'when shared runners are disabled for namespace' do + let!(:namespace_not_inheriting_shared_runners) { create(:namespace, shared_runners_enabled: false) } + + it "does not return a namespace not inheriting shared runners" do + is_expected.not_to include(namespace_not_inheriting_shared_runners) + end + end + end end describe 'delegate' do @@ -710,6 +730,24 @@ RSpec.describe Namespace do end end + describe '#any_project_with_shared_runners_enabled?' do + subject { namespace.any_project_with_shared_runners_enabled? } + + let!(:project_not_inheriting_shared_runners) do + create(:project, namespace: namespace, shared_runners_enabled: false) + end + + context 'when a child project has shared runners enabled' do + let!(:project_inheriting_shared_runners) { create(:project, namespace: namespace, shared_runners_enabled: true) } + + it { is_expected.to eq true } + end + + context 'when all child projects have shared runners disabled' do + it { is_expected.to eq false } + end + end + describe '.search' do let_it_be(:first_group) { create(:group, name: 'my first namespace', path: 'old-path') } let_it_be(:parent_group) { create(:group, name: 'my parent namespace', path: 'parent-path') } |