-
-
Save samflores/028720af6c30c03b0bd2 to your computer and use it in GitHub Desktop.
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
class User < ActiveRecord::Base | |
validates :username, presence: :true | |
validates :password_digest, presence: :true | |
has_secure_password | |
end |
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
test "username is required" do | |
@user = User.new(password: 's3kr3t') | |
assert [email protected]? && @user.errors[:username].include?("can't be blank") | |
end | |
test "password is required" do | |
@user = User.new(username: 'johndoe') | |
assert [email protected]? && @user.errors[:password].include?("can't be blank") | |
end | |
# de acordo com a documentação has_secure_password não adiciona validação de tamanho do campo password | |
# http://api.rubyonrails.org/classes/ActiveModel/SecurePassword/ClassMethods.html#method-i-has_secure_password |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment