1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-07-24 15:49:39 +02:00

Onboarding redirect tests and trial status bar (#2197)
Some checks failed
Publish Docker image / ci (push) Has been cancelled
Publish Docker image / Build docker image (push) Has been cancelled

* Onboarding redirect tests and trial status bar

* use helper method

* Fix time tolerance failure

* Update post-onboarding message to be generic

* Disable turbo frames on Trial start button

* Update flash notice in test
This commit is contained in:
Zach Gollwitzer 2025-05-02 15:21:46 -04:00 committed by GitHub
parent bc7e32deab
commit 441f436187
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 110 additions and 18 deletions

View file

@ -18,11 +18,7 @@ module Onboardable
return unless Current.user
return unless redirectable_path?(request.path)
# Check if trial was started VERY recently (e.g., within the last few seconds)
# If so, assume onboarding was just completed in the previous request, even if onboarded_at appears blank momentarily.
trial_just_started = Current.family.trial_started_at.present? && Current.family.trial_started_at > 10.seconds.ago
if Current.user.onboarded_at.blank? && !trial_just_started
if !Current.user.onboarded?
redirect_to onboarding_path
elsif !Current.family.subscribed? && !Current.family.trialing? && !self_hosted?
redirect_to upgrade_subscription_path

View file

@ -14,7 +14,6 @@ class OnboardingsController < ApplicationController
end
private
def set_user
@user = Current.user
end

View file

@ -8,16 +8,14 @@ class SubscriptionsController < ApplicationController
end
def start_trial
if Current.family.trial_started_at.present?
redirect_to root_path, alert: "You've already started or completed your trial"
else
Family.transaction do
Current.family.update(trial_started_at: Time.current)
Current.user.update(onboarded_at: Time.current)
unless Current.family.trialing?
ActiveRecord::Base.transaction do
Current.user.update!(onboarded_at: Time.current)
Current.family.update!(trial_started_at: Time.current)
end
redirect_to root_path, notice: "Your trial has started"
end
redirect_to root_path, notice: "Welcome to Maybe!"
end
def new