mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
automatically include ActiveModel::Validations when include ActiveModel::SecurePassword
This commit is contained in:
parent
c8f017682e
commit
7b1a42c057
4 changed files with 6 additions and 2 deletions
|
@ -1,6 +1,7 @@
|
|||
module ActiveModel
|
||||
module SecurePassword
|
||||
extend ActiveSupport::Concern
|
||||
include ActiveModel::Validations
|
||||
|
||||
# BCrypt hash function can handle maximum 72 characters, and if we pass
|
||||
# password of length more than 72 characters it ignores extra characters.
|
||||
|
|
|
@ -20,6 +20,11 @@ class SecurePasswordTest < ActiveModel::TestCase
|
|||
ActiveModel::SecurePassword.min_cost = @original_min_cost
|
||||
end
|
||||
|
||||
test "user object should respond to valid?" do
|
||||
assert_respond_to @visitor, :valid?
|
||||
assert_respond_to @user, :valid?
|
||||
end
|
||||
|
||||
test "create/update without validations" do
|
||||
assert @visitor.valid?(:create), 'visitor should be valid'
|
||||
assert @visitor.valid?(:update), 'visitor should be valid'
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
class User
|
||||
extend ActiveModel::Callbacks
|
||||
include ActiveModel::Validations
|
||||
include ActiveModel::SecurePassword
|
||||
|
||||
define_model_callbacks :create
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
class Visitor
|
||||
extend ActiveModel::Callbacks
|
||||
include ActiveModel::Validations
|
||||
include ActiveModel::SecurePassword
|
||||
|
||||
define_model_callbacks :create
|
||||
|
|
Loading…
Reference in a new issue