-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5051 from plataformatec/mf-revert-update-encrypte…
…d-password-to-nil-if-password-is-nil Reverts both "[#4245] Allow password to nil (#4261)" and "Add more tests (#4970)"
- Loading branch information
Showing
2 changed files
with
5 additions
and
23 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -117,9 +117,9 @@ def setup | |
assert_nil user.authenticatable_salt | ||
end | ||
|
||
test 'should set encrypted password to nil if password is nil' do | ||
assert_nil new_user(password: nil).encrypted_password | ||
assert_nil new_user(password: '').encrypted_password | ||
test 'should not generate a hashed password if password is blank' do | ||
assert_blank new_user(password: nil).encrypted_password | ||
assert_blank new_user(password: '').encrypted_password | ||
end | ||
|
||
test 'should hash password again if password has changed' do | ||
|
@@ -148,16 +148,6 @@ def setup | |
refute user.valid_password?('654321') | ||
end | ||
|
||
test 'should be invalid if the password is nil' do | ||
user = new_user(password: nil) | ||
refute user.valid_password?(nil) | ||
end | ||
|
||
test 'should be invalid if the password is blank' do | ||
user = new_user(password: '') | ||
refute user.valid_password?('') | ||
end | ||
|
||
test 'should respond to current password' do | ||
assert new_user.respond_to?(:current_password) | ||
end | ||
|
@@ -317,11 +307,4 @@ def setup | |
] | ||
end | ||
end | ||
|
||
test 'nil password should be invalid if password is set to nil' do | ||
user = User.create(email: "[email protected]", password: "12345678") | ||
user.password = nil | ||
refute user.valid_password?('12345678') | ||
refute user.valid_password?(nil) | ||
end | ||
end |