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>
This commit is contained in:
@@ -63,4 +63,33 @@ class UserTest < ActiveSupport::TestCase
|
||||
refute user.valid?, "User with last_name longer than 12 chars should be invalid"
|
||||
assert_not_nil user.errors[:last_name], "No validation error for too long last_name"
|
||||
end
|
||||
|
||||
# Test onboarding functionality
|
||||
test "new users should need onboarding by default" do
|
||||
user = User.new(email: "test@example.com", password: "password123")
|
||||
assert user.needs_onboarding?, "New user should need onboarding"
|
||||
assert_not user.onboarding_completed?, "New user should not have completed onboarding"
|
||||
end
|
||||
|
||||
test "should complete onboarding" do
|
||||
user = users(:one)
|
||||
user.update!(onboarding_completed: false)
|
||||
|
||||
assert user.needs_onboarding?, "User should need onboarding initially"
|
||||
|
||||
user.complete_onboarding!
|
||||
|
||||
assert_not user.needs_onboarding?, "User should not need onboarding after completion"
|
||||
assert user.onboarding_completed?, "User should have completed onboarding"
|
||||
end
|
||||
|
||||
test "needs_onboarding? should return correct value" do
|
||||
user = users(:one)
|
||||
|
||||
user.update!(onboarding_completed: false)
|
||||
assert user.needs_onboarding?, "User with false onboarding_completed should need onboarding"
|
||||
|
||||
user.update!(onboarding_completed: true)
|
||||
assert_not user.needs_onboarding?, "User with true onboarding_completed should not need onboarding"
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user