58 lines
1.6 KiB
Ruby
58 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
|