Commit 41ea3080 authored by Avielle Wolfe's avatar Avielle Wolfe

Keep shared runner UI after model change

Even though we are now counting minutes when shared runners are
disabled, we don't want to show that information in the UI, since it may
be confusing to users to see minutes being counted after they have
disabled shared runners. Avoiding changes to the UI involves re-adding a
check for Namespace#any_project_with_shared_runners_enabled? in some
places.
parent c1841246
......@@ -25,7 +25,7 @@ module Ci
end
def monthly_percent_used
return 0 unless enabled?
return 0 unless enabled? && any_project_enabled?
return 0 if monthly_minutes == 0
100 * monthly_minutes_used.to_i / monthly_minutes
......@@ -81,6 +81,12 @@ module Ci
private
def any_project_enabled?
strong_memoize(:any_project_enabled) do
namespace.any_project_with_shared_runners_enabled?
end
end
# TODO: rename to `enabled?`
# https://gitlab.com/gitlab-org/gitlab/-/issues/332933
def limit_enabled?
......@@ -90,9 +96,9 @@ module Ci
end
def minutes_limit
return monthly_minutes if enabled?
return monthly_minutes if enabled? && any_project_enabled?
if namespace_eligible?
if namespace_eligible? && any_project_enabled?
_('Unlimited')
else
_('Not supported')
......
- namespace = local_assigns.fetch(:namespace)
- minutes_quota = namespace.ci_minutes_quota
- if minutes_quota.namespace_eligible?
- if namespace.any_project_with_shared_runners_enabled?
%li
%span.light= _('Pipeline minutes quota:')
%strong
......
......@@ -63,6 +63,7 @@ RSpec.describe EE::NamespacesHelper do
context 'and the namespace is eligible for unlimited' do
before do
allow(quota).to receive(:namespace_eligible?).and_return(true)
allow(user_group).to receive(:any_project_with_shared_runners_enabled?).and_return(true)
end
it 'returns Unlimited for the limit section' do
......
......@@ -68,6 +68,7 @@ RSpec.describe Ci::Minutes::Quota do
before do
allow(quota).to receive(:enabled?).and_return(false)
allow(quota).to receive(:namespace_eligible?).and_return(namespace_eligible)
allow(namespace).to receive(:any_project_with_shared_runners_enabled?).and_return(true)
end
context 'when the namespace is not eligible' do
......@@ -114,6 +115,7 @@ RSpec.describe Ci::Minutes::Quota do
context 'when limited' do
before do
allow(quota).to receive(:enabled?).and_return(true)
allow(namespace).to receive(:any_project_with_shared_runners_enabled?).and_return(true)
namespace.shared_runners_minutes_limit = 100
end
......@@ -257,6 +259,7 @@ RSpec.describe Ci::Minutes::Quota do
with_them do
before do
allow(quota).to receive(:enabled?).and_return(limit_enabled)
allow(namespace).to receive(:any_project_with_shared_runners_enabled?).and_return(true)
namespace.shared_runners_minutes_limit = monthly_limit
namespace.extra_shared_runners_minutes_limit = purchased_limit
namespace.namespace_statistics.shared_runners_seconds = minutes_used.minutes
......
......@@ -202,7 +202,7 @@ RSpec.describe PipelineSerializer do
# Existing numbers are high and require performance optimization
# Ongoing issue:
# https://gitlab.com/gitlab-org/gitlab/-/issues/225156
expected_queries = Gitlab.ee? ? 77 : 70
expected_queries = Gitlab.ee? ? 74 : 70
expect(recorded.count).to be_within(2).of(expected_queries)
expect(recorded.cached_count).to eq(0)
......
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