2025-05-02 15:21:46 -04:00
|
|
|
require "test_helper"
|
|
|
|
|
|
|
|
class OnboardableTest < ActionDispatch::IntegrationTest
|
|
|
|
setup do
|
|
|
|
sign_in @user = users(:empty)
|
2025-05-06 14:05:21 -04:00
|
|
|
@user.family.subscription.destroy
|
2025-05-02 15:21:46 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
test "must complete onboarding before any other action" do
|
|
|
|
@user.update!(onboarded_at: nil)
|
|
|
|
|
|
|
|
get root_path
|
|
|
|
assert_redirected_to onboarding_path
|
|
|
|
end
|
|
|
|
|
2025-05-06 14:05:21 -04:00
|
|
|
test "must have subscription to visit dashboard" do
|
2025-05-02 15:21:46 -04:00
|
|
|
@user.update!(onboarded_at: 1.day.ago)
|
|
|
|
|
|
|
|
get root_path
|
2025-05-06 14:05:21 -04:00
|
|
|
assert_redirected_to trial_onboarding_path
|
2025-05-02 15:21:46 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
test "onboarded subscribed user can visit dashboard" do
|
|
|
|
@user.update!(onboarded_at: 1.day.ago)
|
2025-05-06 14:05:21 -04:00
|
|
|
@user.family.start_trial_subscription!
|
2025-05-02 15:21:46 -04:00
|
|
|
|
|
|
|
get root_path
|
|
|
|
assert_response :success
|
|
|
|
end
|
|
|
|
end
|