Files
aperonight/test/controllers/application_controller_onboarding_test.rb
kbe 758d461c1a feat: Implement comprehensive onboarding system for new users
Add complete user onboarding flow that redirects new users to complete their
profile before accessing the application:

- Add onboarding_completed boolean field to users with migration
- Create OnboardingController with form validation and completion logic
- Design professional onboarding UI with progressive disclosure for company info
- Implement Stimulus controller for toggling company information section
- Add application-wide redirect middleware for incomplete users
- Create comprehensive test suite for all onboarding functionality
- Update test fixtures and helpers to support onboarding in existing tests

The onboarding collects required first/last name and optional company information.
Users are redirected to onboarding after login until profile is completed.
Features smooth animations, full-width form button, and clean UX design.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-08 11:38:28 +02:00

57 lines
1.6 KiB
Ruby

require "test_helper"
class ApplicationControllerOnboardingTest < ActionDispatch::IntegrationTest
setup do
@user_without_onboarding = users(:one)
@user_without_onboarding.update!(onboarding_completed: false)
@user_with_onboarding = users(:two)
@user_with_onboarding.update!(onboarding_completed: true, first_name: "John", last_name: "Doe")
end
test "should redirect incomplete users to onboarding from dashboard" do
sign_in @user_without_onboarding
get dashboard_path
assert_redirected_to onboarding_path
end
test "should allow complete users to access dashboard" do
sign_in @user_with_onboarding
get dashboard_path
assert_response :success
end
test "should redirect incomplete users to onboarding from events" do
sign_in @user_without_onboarding
get events_path
assert_redirected_to onboarding_path
end
test "should allow complete users to access events" do
sign_in @user_with_onboarding
get events_path
assert_response :success
end
test "should not redirect from home page when not signed in" do
get root_path
assert_response :success
end
test "should redirect signed in incomplete users from home to onboarding" do
sign_in @user_without_onboarding
get root_path
assert_redirected_to dashboard_path # Home redirects to dashboard for signed in users
end
test "should not interfere with devise controllers" do
get new_user_session_path
assert_response :success
end
test "should not redirect when already on onboarding page" do
sign_in @user_without_onboarding
get onboarding_path
assert_response :success
end
end