Early return from SubscriptionsController actions when redirecting or rendering a different view
What does this MR do and why?
Issue: https://gitlab.com/gitlab-org/gitlab/-/issues/472207+
This MR adds early return
statements to the redirects and renders in the SubscriptionsController
actions for the purchase flows.
Prior to this change, if an unauthenticated user reached this URL (ie, from the marketing site), we would redirect them to the registration page, but we'd still execute all the code in the new
action.
This was resulting in a 500
error after enabling the purchase flow migration FFs, as we start calling methods on the current_user
object. Instead, lets short-circuit in this case, and just return.
I've also updated the specs to stub less, and ensure we would catch an issue like this in the future.
MR acceptance checklist
Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Screenshots or screen recordings
Before | After |
---|---|
How to set up and validate locally
Start the GDk and CustomersDot.
- Enable the purchase flow migration FFs
Feature.enable(:migrate_purchase_flows_for_existing_customers) Feature.enable(:migrate_purchase_flows_for_new_customers)
- Navigate to http://localhost:3000/-/subscriptions/new?plan_id=2c92a00d76f0d5060176f2fb0a5029ff
- The sign up page should render without error, and signing in should take you back to the purchase flow