Commit b6a75761 authored by Rubén Dávila's avatar Rubén Dávila

Add feature flag

I'm adding a feature flag that will allow us to disable this feature in
case we detect a performance issue.
parent b5065b42
......@@ -94,6 +94,7 @@ class GitlabSubscription < ApplicationRecord
# We need to show seats in use for free or trial subscriptions
# in order to make it easy for customers to get this information.
def seats_in_use
return super unless Feature.enabled?(:seats_in_use_for_free_or_trial, type: :ops, default_enabled: true)
return super if has_a_paid_hosted_plan? || !hosted?
seats_in_use_now
......
---
name: seats-in-use-for-free-or-trial
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/44973
rollout_issue_url:
type: ops
group: group::provision
default_enabled: true
......@@ -211,6 +211,18 @@ RSpec.describe GitlabSubscription do
create(:gitlab_subscription, namespace: group, trial: trial, hosted_plan: hosted_plan, seats_in_use: seats_in_use)
end
shared_examples 'a disabled feature' do
context 'when feature flag is disabled' do
before do
stub_feature_flags(seats_in_use_for_free_or_trial: false)
end
it 'returns the previously calculated seats in use' do
expect(subject).to eq(5)
end
end
end
subject { gitlab_subscription.seats_in_use }
context 'with a paid hosted plan' do
......@@ -236,6 +248,8 @@ RSpec.describe GitlabSubscription do
it 'returns the current seats in use' do
expect(subject).to eq(1)
end
it_behaves_like 'a disabled feature'
end
context 'with a free plan' do
......@@ -244,6 +258,8 @@ RSpec.describe GitlabSubscription do
it 'returns the current seats in use' do
expect(subject).to eq(1)
end
it_behaves_like 'a disabled feature'
end
context 'with a self hosted plan' 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