sample_rails_tailwind/test/integration/users_signup_test.rb
songtianlun 9fac43f46d feat: add user registration functionality
- Implement user creation in UsersController
- Add user registration form in new.html.erb
- Create error messages partial for form validation
- Add gravatar helper for user profile
- Update routes to include resources for users
- Introduce integration tests for signup validation

This commit establishes the foundation for user registration, allowing users to sign up with their details and providing feedback on form errors. It enhances the user experience by integrating visual elements like gravatars and error messages.
2024-12-31 16:34:52 +08:00

30 lines
1016 B
Ruby

require "test_helper"
class UsersSignupTest < ActionDispatch::IntegrationTest
test "invalid signup information" do
get signup_path
assert_no_difference 'User.count' do
post users_path, params: { user: { name: "",
email: "user@invalid",
password: "foo",
password_confirmation: "bar" } }
end
assert_template 'users/new'
assert_select 'div#error_explanation'
assert_select 'div.alert-danger'
end
test "valid signup information" do
get signup_path
assert_difference 'User.count', 1 do
post users_path, params: { user: {name: "Example User",
email: "user@example.com",
password: "password",
password_confirmation: "password" } }
end
follow_redirect!
assert_template 'users/show'
assert_not flash.notice
end
end