Skip to content
Snippets Groups Projects
Verified Commit 41ea3080 authored by Avielle Wolfe's avatar Avielle Wolfe :three:
Browse files

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
No related branches found
No related tags found
1 merge request!67024Track build minutes for disabled shared runners
......@@ -25,7 +25,7 @@ def monthly_minutes_report
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 @@ def current_balance
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 @@ def limit_enabled?
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 @@
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 @@
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 @@
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 @@
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 @@ def ref
# 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)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment