Completely remove the enterprise/company information functionality from the onboarding flow to simplify the user experience: - Remove company information toggle section and form fields from view - Delete unused Stimulus toggle controller (toggle_section_controller.js) - Update onboarding controller to only process first/last name parameters - Remove company_name from permitted parameters and validation logic - Update tests to remove company name assertions and test cases - Simplify onboarding to only collect essential personal information The onboarding now focuses solely on collecting required first and last names, providing a cleaner and faster user experience. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
87 lines
2.4 KiB
Ruby
87 lines
2.4 KiB
Ruby
require "test_helper"
|
|
|
|
class OnboardingControllerTest < 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 to onboarding when user not signed in" do
|
|
get onboarding_path
|
|
assert_redirected_to new_user_session_path
|
|
end
|
|
|
|
test "should show onboarding page for incomplete user" do
|
|
sign_in @user_without_onboarding
|
|
get onboarding_path
|
|
assert_response :success
|
|
assert_select "h1", /Bienvenue sur.*!/
|
|
assert_select "form"
|
|
end
|
|
|
|
test "should redirect completed user to dashboard" do
|
|
sign_in @user_with_onboarding
|
|
get onboarding_path
|
|
assert_redirected_to dashboard_path
|
|
end
|
|
|
|
test "should complete onboarding with valid data" do
|
|
sign_in @user_without_onboarding
|
|
|
|
assert_not @user_without_onboarding.onboarding_completed?
|
|
|
|
post complete_onboarding_path, params: {
|
|
user: {
|
|
first_name: "Jane",
|
|
last_name: "Smith"
|
|
}
|
|
}
|
|
|
|
assert_redirected_to dashboard_path
|
|
follow_redirect!
|
|
assert_select ".notification", /Bienvenue sur AperoNight/
|
|
|
|
@user_without_onboarding.reload
|
|
assert @user_without_onboarding.onboarding_completed?
|
|
assert_equal "Jane", @user_without_onboarding.first_name
|
|
assert_equal "Smith", @user_without_onboarding.last_name
|
|
end
|
|
|
|
test "should not complete onboarding without required fields" do
|
|
sign_in @user_without_onboarding
|
|
|
|
post complete_onboarding_path, params: {
|
|
user: {
|
|
first_name: "",
|
|
last_name: "Smith"
|
|
}
|
|
}
|
|
|
|
assert_response :success
|
|
assert_select ".notification", /Veuillez remplir tous les champs requis/
|
|
|
|
@user_without_onboarding.reload
|
|
assert_not @user_without_onboarding.onboarding_completed?
|
|
end
|
|
|
|
test "should not complete onboarding without last name" do
|
|
sign_in @user_without_onboarding
|
|
|
|
post complete_onboarding_path, params: {
|
|
user: {
|
|
first_name: "Jane",
|
|
last_name: ""
|
|
}
|
|
}
|
|
|
|
assert_response :success
|
|
assert_select ".notification", /Veuillez remplir tous les champs requis/
|
|
|
|
@user_without_onboarding.reload
|
|
assert_not @user_without_onboarding.onboarding_completed?
|
|
end
|
|
end
|