Commit 864fa093 authored by ayufanpl's avatar ayufanpl

Flip shared_runner_minutes_on_subnamespace to shared_runner_minutes_on_root_namespace

parent a6bfa4b8
...@@ -11,10 +11,10 @@ class Groups::PipelineQuotaController < Groups::ApplicationController ...@@ -11,10 +11,10 @@ class Groups::PipelineQuotaController < Groups::ApplicationController
private private
def all_projects def all_projects
if Feature.enabled?(:shared_runner_minutes_on_subnamespace) if Feature.enabled?(:shared_runner_minutes_on_root_namespace)
@group.projects
else
@group.all_projects @group.all_projects
else
@group.projects
end end
end end
......
...@@ -95,7 +95,7 @@ module EE ...@@ -95,7 +95,7 @@ module EE
def shared_runner_minutes_supported? def shared_runner_minutes_supported?
if has_parent? if has_parent?
Feature.enabled?(:shared_runner_minutes_on_subnamespace) !Feature.enabled?(:shared_runner_minutes_on_root_namespace)
else else
true true
end end
...@@ -118,10 +118,10 @@ module EE ...@@ -118,10 +118,10 @@ module EE
end end
def shared_runners_enabled? def shared_runners_enabled?
if Feature.enabled?(:shared_runner_minutes_on_subnamespace) if Feature.enabled?(:shared_runner_minutes_on_root_namespace)
projects.with_shared_runners.any?
else
all_projects.with_shared_runners.any? all_projects.with_shared_runners.any?
else
projects.with_shared_runners.any?
end end
end end
......
...@@ -83,10 +83,10 @@ module EE ...@@ -83,10 +83,10 @@ module EE
end end
def shared_runners_limit_namespace def shared_runners_limit_namespace
if Feature.enabled?(:shared_runner_minutes_on_subnamespace) if Feature.enabled?(:shared_runner_minutes_on_root_namespace)
namespace
else
root_namespace root_namespace
else
namespace
end end
end end
......
...@@ -28,7 +28,7 @@ module EE ...@@ -28,7 +28,7 @@ module EE
def all_namespaces def all_namespaces
namespaces = ::Namespace.reorder(nil).where('namespaces.id = projects.namespace_id') namespaces = ::Namespace.reorder(nil).where('namespaces.id = projects.namespace_id')
unless Feature.enabled?(:shared_runner_minutes_on_subnamespace) if Feature.enabled?(:shared_runner_minutes_on_root_namespace)
namespaces = ::Gitlab::GroupHierarchy.new(namespaces).roots namespaces = ::Gitlab::GroupHierarchy.new(namespaces).roots
end end
......
...@@ -101,9 +101,9 @@ feature 'Groups > Pipeline Quota' do ...@@ -101,9 +101,9 @@ feature 'Groups > Pipeline Quota' do
end end
end end
context 'with shared_runner_minutes_on_subnamespace enabled' do context 'with shared_runner_minutes_on_root_namespace disabled' do
before do before do
stub_feature_flags(shared_runner_minutes_on_subnamespace: true) stub_feature_flags(shared_runner_minutes_on_root_namespace: false)
end end
context 'when accessing group with subgroups' do context 'when accessing group with subgroups' do
...@@ -120,9 +120,9 @@ feature 'Groups > Pipeline Quota' do ...@@ -120,9 +120,9 @@ feature 'Groups > Pipeline Quota' do
end end
end end
context 'with shared_runner_minutes_on_subnamespace disabled' do context 'with shared_runner_minutes_on_root_namespace enabled' do
before do before do
stub_feature_flags(shared_runner_minutes_on_subnamespace: false) stub_feature_flags(shared_runner_minutes_on_root_namespace: true)
end end
context 'when accessing subgroup' do context 'when accessing subgroup' do
......
...@@ -66,7 +66,7 @@ describe Namespace do ...@@ -66,7 +66,7 @@ describe Namespace do
describe '#validate_shared_runner_minutes_support' do describe '#validate_shared_runner_minutes_support' do
before do before do
stub_feature_flags(shared_runner_minutes_on_subnamespace: false) stub_feature_flags(shared_runner_minutes_on_root_namespace: true)
end end
context 'when changing :shared_runners_minutes_limit' do context 'when changing :shared_runners_minutes_limit' do
...@@ -331,9 +331,9 @@ describe Namespace do ...@@ -331,9 +331,9 @@ describe Namespace do
namespace.parent = build(:group) namespace.parent = build(:group)
end end
context 'when shared_runner_minutes_on_subnamespace is enabled' do context 'when shared_runner_minutes_on_root_namespace is disabled' do
before do before do
stub_feature_flags(shared_runner_minutes_on_subnamespace: true) stub_feature_flags(shared_runner_minutes_on_root_namespace: false)
end end
it 'returns true' do it 'returns true' do
...@@ -341,9 +341,9 @@ describe Namespace do ...@@ -341,9 +341,9 @@ describe Namespace do
end end
end end
context 'when shared_runner_minutes_on_subnamespace is disalbed' do context 'when shared_runner_minutes_on_root_namespace is enabled' do
before do before do
stub_feature_flags(shared_runner_minutes_on_subnamespace: false) stub_feature_flags(shared_runner_minutes_on_root_namespace: true)
end end
it 'returns false' do it 'returns false' do
...@@ -382,7 +382,7 @@ describe Namespace do ...@@ -382,7 +382,7 @@ describe Namespace do
context 'when is subgroup' do context 'when is subgroup' do
before do before do
stub_feature_flags(shared_runner_minutes_on_subnamespace: false) stub_feature_flags(shared_runner_minutes_on_root_namespace: true)
namespace.parent = build(:group) namespace.parent = build(:group)
end end
...@@ -403,9 +403,9 @@ describe Namespace do ...@@ -403,9 +403,9 @@ describe Namespace do
let(:subgroup) { create(:group, parent: namespace) } let(:subgroup) { create(:group, parent: namespace) }
let!(:subproject) { create(:project, namespace: subgroup, shared_runners_enabled: true) } let!(:subproject) { create(:project, namespace: subgroup, shared_runners_enabled: true) }
context 'when shared_runner_minutes_on_subnamespace is enabled' do context 'when shared_runner_minutes_on_root_namespace is disabled' do
before do before do
stub_feature_flags(shared_runner_minutes_on_subnamespace: true) stub_feature_flags(shared_runner_minutes_on_root_namespace: false)
end end
it "returns false" do it "returns false" do
...@@ -413,9 +413,9 @@ describe Namespace do ...@@ -413,9 +413,9 @@ describe Namespace do
end end
end end
context 'when shared_runner_minutes_on_subnamespace is disabled' do context 'when shared_runner_minutes_on_root_namespace is enabled' do
before do before do
stub_feature_flags(shared_runner_minutes_on_subnamespace: false) stub_feature_flags(shared_runner_minutes_on_root_namespace: true)
end end
it "returns true" do it "returns true" do
......
...@@ -539,9 +539,9 @@ describe Project do ...@@ -539,9 +539,9 @@ describe Project do
subject { project.shared_runners_limit_namespace } subject { project.shared_runners_limit_namespace }
context 'when shared_runner_minutes_on_subnamespace is enabled' do context 'when shared_runner_minutes_on_root_namespace is disabled' do
before do before do
stub_feature_flags(shared_runner_minutes_on_subnamespace: true) stub_feature_flags(shared_runner_minutes_on_root_namespace: false)
end end
it 'returns parent namespace' do it 'returns parent namespace' do
...@@ -549,9 +549,9 @@ describe Project do ...@@ -549,9 +549,9 @@ describe Project do
end end
end end
context 'when shared_runner_minutes_on_subnamespace is disabled' do context 'when shared_runner_minutes_on_root_namespace is enabled' do
before do before do
stub_feature_flags(shared_runner_minutes_on_subnamespace: false) stub_feature_flags(shared_runner_minutes_on_root_namespace: true)
end end
it 'returns root namespace' do it 'returns root namespace' do
......
...@@ -69,9 +69,9 @@ module Ci ...@@ -69,9 +69,9 @@ module Ci
let!(:project) { create :project, shared_runners_enabled: true, group: group } let!(:project) { create :project, shared_runners_enabled: true, group: group }
let(:build) { execute(shared_runner) } let(:build) { execute(shared_runner) }
context 'when shared_runner_minutes_on_subnamespace is enabled' do context 'when shared_runner_minutes_on_root_namespace is disabled' do
before do before do
stub_feature_flags(shared_runner_minutes_on_subnamespace: true) stub_feature_flags(shared_runner_minutes_on_root_namespace: false)
end end
it "does return a build" do it "does return a build" do
...@@ -90,9 +90,9 @@ module Ci ...@@ -90,9 +90,9 @@ module Ci
end end
end end
context 'when shared_runner_minutes_on_subnamespace is disabled' do context 'when shared_runner_minutes_on_root_namespace is enabled' do
before do before do
stub_feature_flags(shared_runner_minutes_on_subnamespace: false) stub_feature_flags(shared_runner_minutes_on_root_namespace: true)
end end
it "does return a build" do it "does return a build" do
......
...@@ -10,9 +10,9 @@ describe 'admin/groups/_form' do ...@@ -10,9 +10,9 @@ describe 'admin/groups/_form' do
allow(view).to receive(:visibility_level) { group.visibility_level } allow(view).to receive(:visibility_level) { group.visibility_level }
end end
describe 'when :shared_runner_minutes_on_subnamespace is enabled' do describe 'when :shared_runner_minutes_on_root_namespace is disabled' do
before do before do
stub_feature_flags(shared_runner_minutes_on_subnamespace: true) stub_feature_flags(shared_runner_minutes_on_root_namespace: false)
end end
context 'when sub group is used' do context 'when sub group is used' do
...@@ -27,9 +27,9 @@ describe 'admin/groups/_form' do ...@@ -27,9 +27,9 @@ describe 'admin/groups/_form' do
end end
end end
describe 'when :shared_runner_minutes_on_subnamespace is disabled' do describe 'when :shared_runner_minutes_on_root_namespace is enabled' do
before do before do
stub_feature_flags(shared_runner_minutes_on_subnamespace: false) stub_feature_flags(shared_runner_minutes_on_root_namespace: true)
end end
context 'when sub group is used' do context 'when sub group is used' do
......
RSpec.configure do |config|
config.before(:all) do
puts "this feature is by default disabled"
Feature.get(:shared_runner_minutes_on_subnamespace).disable
end
end
...@@ -46,11 +46,11 @@ describe UpdateBuildMinutesService do ...@@ -46,11 +46,11 @@ describe UpdateBuildMinutesService do
context 'when namespace is subgroup' do context 'when namespace is subgroup' do
let(:root_ancestor) { create(:group, shared_runners_minutes_limit: 100) } let(:root_ancestor) { create(:group, shared_runners_minutes_limit: 100) }
context 'when shared_runner_minutes_on_subnamespace is enabled' do context 'when shared_runner_minutes_on_root_namespace is disabled' do
let(:namespace) { create(:namespace, parent: root_ancestor, shared_runners_minutes_limit: 100) } let(:namespace) { create(:namespace, parent: root_ancestor, shared_runners_minutes_limit: 100) }
before do before do
stub_feature_flags(shared_runner_minutes_on_subnamespace: true) stub_feature_flags(shared_runner_minutes_on_root_namespace: false)
end end
it 'creates a statistics in current namespace' do it 'creates a statistics in current namespace' do
...@@ -61,11 +61,11 @@ describe UpdateBuildMinutesService do ...@@ -61,11 +61,11 @@ describe UpdateBuildMinutesService do
end end
end end
context 'when shared_runner_minutes_on_subnamespace is disabled' do context 'when shared_runner_minutes_on_root_namespace is enabled' do
let(:namespace) { create(:namespace, parent: root_ancestor) } let(:namespace) { create(:namespace, parent: root_ancestor) }
before do before do
stub_feature_flags(shared_runner_minutes_on_subnamespace: false) stub_feature_flags(shared_runner_minutes_on_root_namespace: true)
end end
it 'creates a statistics in root namespace' do it 'creates a statistics in root namespace' do
......
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