Commit 0f14224e authored by Josianne Hyson's avatar Josianne Hyson

Use old purchase flow when user last name is blank

The customers app requires a last name for the creation of the customer
record. As the new purchase flow does not currently have a way for users
to set a last name, fallback to the old flow when the user does not have
a last name set. This was causing issues with users in the following
state:

  1. User does not have a last name (signed up before we split the name
     field) and their full name only has one word
  2. User does not have an existing customers dot account
  3. User is creating the subscription on .com
  4. User is creating the subscription for a group (ie, using the
     purchase flow that does not redirect to customers-dot)

Issue: https://gitlab.com/gitlab-org/gitlab/-/issues/298721
parent 77c27fd9
......@@ -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