Commit 2e9dd569 authored by Fabio Pitino's avatar Fabio Pitino

Add feature flag to extend credit card requirement

Extend CC requirement to old users by enabling a FF
which is disabled by default.
parent 3c832e79
......@@ -412,8 +412,9 @@ module EE
private
def created_after_credit_card_release_day?
created_at >= ::Users::CreditCardValidation::RELEASE_DAY
def created_after_credit_card_release_day?(project)
created_at >= ::Users::CreditCardValidation::RELEASE_DAY ||
::Feature.enabled?(:ci_require_credit_card_for_old_users, project, default_enabled: :yaml)
end
def has_valid_credit_card?
......@@ -422,7 +423,7 @@ module EE
def requires_credit_card_to_run_pipelines?(project)
return false unless ::Gitlab.com?
return false unless created_after_credit_card_release_day?
return false unless created_after_credit_card_release_day?(project)
root_namespace = project.root_namespace
if root_namespace.free_plan?
......
---
name: ci_require_credit_card_for_old_users
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/61565
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/330706
milestone: '13.12'
type: development
group: group::continuous integration
default_enabled: false
......@@ -1683,21 +1683,23 @@ RSpec.describe User do
using RSpec::Parameterized::TableSyntax
where(:is_saas, :cc_present, :is_free, :is_trial, :free_ff_enabled, :trial_ff_enabled, :days_from_release, :result) do
where(:is_saas, :cc_present, :is_free, :is_trial, :free_ff_enabled, :trial_ff_enabled, :old_users_ff_enabled, :days_from_release, :result, :description) do
# self-hosted
false | false | false | false | true | true | 0 | true # paid plan
false | false | false | true | true | true | 0 | true # missing CC on trial plan
false | false | false | false | true | true | false | 0 | true | 'self-hosted paid plan'
false | false | false | true | true | true | false | 0 | true | 'self-hosted missing CC on trial plan'
# saas
true | false | false | false | true | true | 0 | true # missing CC on paid plan
true | false | true | false | true | true | 0 | false # missing CC on free plan
true | false | true | false | true | true | -1 | true # missing CC on free plan but old user
true | false | true | false | false | true | 0 | true # missing CC on free plan - FF off
true | false | false | true | true | true | 0 | false # missing CC on trial plan
true | false | false | true | true | true | -1 | true # missing CC on trial plan but old user
true | false | false | true | true | false | 0 | true # missing CC on trial plan - FF off
true | true | true | false | true | true | 0 | true # present CC on free plan
true | true | false | true | true | true | 0 | true # present CC on trial plan
true | false | false | false | true | true | false | 0 | true | 'missing CC on paid plan'
true | false | true | false | true | true | false | 0 | false | 'missing CC on free plan'
true | false | true | false | true | true | false | -1 | true | 'missing CC on free plan but old user'
true | false | true | false | true | true | true | -1 | false | 'missing CC on free plan but old user and FF enabled'
true | false | true | false | false | true | false | 0 | true | 'missing CC on free plan - FF off'
true | false | false | true | true | true | false | 0 | false | 'missing CC on trial plan'
true | false | false | true | true | true | false | -1 | true | 'missing CC on trial plan but old user'
true | false | false | true | true | true | true | -1 | false | 'missing CC on trial plan but old user and FF enabled'
true | false | false | true | true | false | false | 0 | true | 'missing CC on trial plan - FF off'
true | true | true | false | true | true | false | 0 | true | 'present CC on free plan'
true | true | false | true | true | true | false | 0 | true | 'present CC on trial plan'
end
with_them do
......@@ -1709,10 +1711,13 @@ RSpec.describe User do
allow(project.namespace).to receive(:trial?).and_return(is_trial)
stub_feature_flags(
ci_require_credit_card_on_free_plan: free_ff_enabled,
ci_require_credit_card_on_trial_plan: trial_ff_enabled)
ci_require_credit_card_on_trial_plan: trial_ff_enabled,
ci_require_credit_card_for_old_users: old_users_ff_enabled)
end
it { is_expected.to eq(result) }
it description do
expect(subject).to eq(result)
end
end
end
......
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