-
-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add configurable password length validation (#64)
* Add configurable password length validation - Replaces the hardcoded password length minimum validator (12 characters) with a configuration variable - Adds test to check validation with multiple configurations - Adds documentation to README.md * Simplify tests * Update user_test.rb --------- Co-authored-by: Chris Oliver <[email protected]>
- Loading branch information
1 parent
623b76f
commit 325afc9
Showing
4 changed files
with
23 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,18 @@ class UserTest < ActiveSupport::TestCase | |
refute_empty user.errors.where(:password, :blank) | ||
end | ||
|
||
test "password meets minimum length" do | ||
valid_user = User.new(email: "[email protected]") | ||
|
||
valid_user.password = "a" * (ReviseAuth.minimum_password_length - 1) | ||
valid_user.valid? | ||
refute_empty valid_user.errors.where(:password, :too_short) | ||
|
||
valid_user.password = "a" * ReviseAuth.minimum_password_length | ||
valid_user.valid? | ||
assert_empty valid_user.errors.where(:password, :too_short) | ||
end | ||
|
||
test "email is downcased" do | ||
user = User.new(email: "[email protected]") | ||
user.valid? | ||
|