Commit b1e4a495 authored by Mark Chao's avatar Mark Chao

Merge branch 'jh-old_purchase_flow_last_name' into 'master'

Use old purchase flow when user last name is blank

See merge request gitlab-org/gitlab!51730
parents 97951c1c 0f14224e
......@@ -25,6 +25,10 @@ module BillingPlansHelper
end
def use_new_purchase_flow?(namespace)
# new flow requires the user to already have a last name.
# This can be removed once https://gitlab.com/gitlab-org/gitlab/-/issues/298715 is complete.
return false unless current_user.last_name.present?
namespace.group? && (namespace.actual_plan_name == Plan::FREE || namespace.trial_active?)
end
......
---
title: Use old purchase flow when user last name is blank
merge_request: 51730
author:
type: changed
......@@ -94,6 +94,36 @@ RSpec.describe BillingPlansHelper do
is_expected.to be(result)
end
end
context 'when the group is on a plan eligible for the new purchase flow' do
let(:namespace) do
create(
:namespace,
type: Group,
gitlab_subscription: create(:gitlab_subscription, hosted_plan: create(:free_plan))
)
end
before do
allow(helper).to receive(:current_user).and_return(user)
end
context 'when the user has a last name' do
let(:user) { build(:user, last_name: 'Lastname') }
it 'returns true' do
expect(helper.use_new_purchase_flow?(namespace)).to eq true
end
end
context 'when the user does not have a last name' do
let(:user) { build(:user, last_name: nil, name: 'Firstname') }
it 'returns false' do
expect(helper.use_new_purchase_flow?(namespace)).to eq false
end
end
end
end
describe '#show_contact_sales_button?' 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