Commit 1a9fda7a authored by Sean McGivern's avatar Sean McGivern Committed by Heinrich Lee Yu

Put dashboard gold trial behind feature flag

This is behind a flag because it's a change in behaviour from the
previous callout. We've fixed when it displays, but it might surprise
some people. So to be cautious, we allow it to be disabled entirely.
parent d0effe70
......@@ -52,7 +52,8 @@ module EE
def render_dashboard_gold_trial(user)
return unless show_gold_trial?(user, GOLD_TRIAL) &&
user_default_dashboard?(user) &&
has_no_trial_or_gold_plan?(user) &&
::Feature.enabled?(:render_dashboard_gold_trial, default_enabled: true) &&
has_no_trial_or_paid_plan?(user) &&
has_some_namespaces_with_no_trials?(user)
render 'shared/gold_trial_callout_content'
......@@ -118,7 +119,7 @@ module EE
::Gitlab.com? && !::Gitlab::Database.read_only?
end
def has_no_trial_or_gold_plan?(user)
def has_no_trial_or_paid_plan?(user)
return false if user.has_paid_namespace?
!user.any_namespace_with_trial?
......
......@@ -177,7 +177,7 @@ describe EE::UserCalloutsHelper do
let_it_be(:gold_plan) { create(:gold_plan) }
let(:user) { namespace.owner }
where(:has_some_namespaces_with_no_trials?, :show_gold_trial?, :user_default_dashboard?, :has_no_trial_or_gold_plan?, :should_render?) do
where(:has_some_namespaces_with_no_trials?, :show_gold_trial?, :user_default_dashboard?, :has_no_trial_or_paid_plan?, :should_render?) do
true | true | true | true | true
true | true | true | false | false
true | true | false | true | false
......@@ -202,7 +202,7 @@ describe EE::UserCalloutsHelper do
allow(helper).to receive(:user_default_dashboard?) { user_default_dashboard? }
allow(helper).to receive(:has_some_namespaces_with_no_trials?) { has_some_namespaces_with_no_trials? }
unless has_no_trial_or_gold_plan?
unless has_no_trial_or_paid_plan?
create(:gitlab_subscription, hosted_plan: gold_plan, namespace: namespace)
end
end
......@@ -217,6 +217,22 @@ describe EE::UserCalloutsHelper do
helper.render_dashboard_gold_trial(user)
end
end
context 'when render_dashboard_gold_trial feature is disabled' do
before do
stub_feature_flags(render_dashboard_gold_trial: false)
allow(helper).to receive(:show_gold_trial?).and_return(true)
allow(helper).to receive(:user_default_dashboard?).and_return(true)
allow(helper).to receive(:has_some_namespaces_with_no_trials?).and_return(true)
end
it 'does not render' do
expect(helper).not_to receive(:render)
helper.render_dashboard_gold_trial(user)
end
end
end
describe '#render_billings_gold_trial' 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