1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/activemodel/test/cases/secure_password_test.rb

33 lines
625 B
Ruby
Raw Normal View History

require 'cases/helper'
require 'models/user'
class SecurePasswordTest < ActiveModel::TestCase
setup do
@user = User.new
end
test "password must be present" do
assert !@user.valid?
assert_equal 1, @user.errors.size
end
test "password must match confirmation" do
@user.password = "thiswillberight"
@user.password_confirmation = "wrong"
assert !@user.valid?
@user.password_confirmation = "thiswillberight"
assert @user.valid?
end
test "authenticate" do
@user.password = "secret"
assert !@user.authenticate("wrong")
assert @user.authenticate("secret")
end
end