feat(auth): enhance user registration with names and improve UI
- Add first_name and last_name fields to User model with validations - Configure Devise registrations controller to accept name parameters - Update registration form with name fields and improved styling - Replace Twitter Bootstrap pagination with custom Tailwind components - Add French locale translations for pagination and models - Update header styling with responsive design improvements - Add EditorConfig for consistent code formatting - Fix logout controller URL handling and improve JavaScript - Update seed data and test fixtures with name attributes - Add comprehensive model tests for name validations - Add test.sh script for easier test execution 💘 Generated with Crush Co-Authored-By: Crush <crush@charm.land>
This commit is contained in:
4
test/fixtures/users.yml
vendored
4
test/fixtures/users.yml
vendored
@@ -3,7 +3,11 @@
|
||||
one:
|
||||
email: user1@example.com
|
||||
encrypted_password: <%= Devise::Encryptor.digest(User, 'password123') %>
|
||||
last_name: Trump
|
||||
first_name: Donald
|
||||
|
||||
two:
|
||||
email: user2@example.com
|
||||
encrypted_password: <%= Devise::Encryptor.digest(User, 'password123') %>
|
||||
last_name: Obama
|
||||
first_name: Barack
|
||||
|
||||
@@ -25,4 +25,42 @@ class UserTest < ActiveSupport::TestCase
|
||||
assert_equal :has_many, association.macro
|
||||
assert_equal :destroy, association.options[:dependent]
|
||||
end
|
||||
|
||||
# Test first_name validations
|
||||
test "should validate presence of first_name" do
|
||||
user = User.new(last_name: "Doe")
|
||||
refute user.valid?, "User with blank first_name should be invalid"
|
||||
assert_not_nil user.errors[:first_name], "No validation error for blank first_name"
|
||||
end
|
||||
|
||||
test "should validate length of first_name" do
|
||||
# Test minimum length
|
||||
user = User.new(first_name: "A", last_name: "Doe")
|
||||
refute user.valid?, "User with first_name shorter than 3 chars should be invalid"
|
||||
assert_not_nil user.errors[:first_name], "No validation error for too short first_name"
|
||||
|
||||
# Test maximum length
|
||||
user = User.new(first_name: "A" * 13, last_name: "Doe")
|
||||
refute user.valid?, "User with first_name longer than 12 chars should be invalid"
|
||||
assert_not_nil user.errors[:first_name], "No validation error for too long first_name"
|
||||
end
|
||||
|
||||
# Test last_name validations
|
||||
test "should validate presence of last_name" do
|
||||
user = User.new(first_name: "John")
|
||||
refute user.valid?, "User with blank last_name should be invalid"
|
||||
assert_not_nil user.errors[:last_name], "No validation error for blank last_name"
|
||||
end
|
||||
|
||||
test "should validate length of last_name" do
|
||||
# Test minimum length
|
||||
user = User.new(first_name: "John", last_name: "Do")
|
||||
refute user.valid?, "User with last_name shorter than 3 chars should be invalid"
|
||||
assert_not_nil user.errors[:last_name], "No validation error for too short last_name"
|
||||
|
||||
# Test maximum length
|
||||
user = User.new(first_name: "John", last_name: "D" * 13)
|
||||
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
|
||||
end
|
||||
Reference in New Issue
Block a user