diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2014-07-02 18:26:55 -0300 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2014-07-02 18:26:55 -0300 |
commit | a4104278b5cc5a7e7b15473c1ea74125f915f2db (patch) | |
tree | ee9fd14d15d3796e354e0ad878b274a687e52faf | |
parent | f625b6879df4d8710c0226007dc0929ed98355d2 (diff) | |
parent | 7b1a42c05707c0e1f793bada3a448fd6f8630f5a (diff) | |
download | rails-a4104278b5cc5a7e7b15473c1ea74125f915f2db.tar.gz rails-a4104278b5cc5a7e7b15473c1ea74125f915f2db.tar.bz2 rails-a4104278b5cc5a7e7b15473c1ea74125f915f2db.zip |
Merge pull request #16024 from aditya-kapoor/include-validations
automatically include ActiveModel::Validations when include ActiveModel::SecurePassword
-rw-r--r-- | activemodel/lib/active_model/secure_password.rb | 1 | ||||
-rw-r--r-- | activemodel/test/cases/secure_password_test.rb | 5 | ||||
-rw-r--r-- | activemodel/test/models/user.rb | 1 | ||||
-rw-r--r-- | activemodel/test/models/visitor.rb | 1 |
4 files changed, 6 insertions, 2 deletions
diff --git a/activemodel/lib/active_model/secure_password.rb b/activemodel/lib/active_model/secure_password.rb index fdfd8cb147..88e578e626 100644 --- a/activemodel/lib/active_model/secure_password.rb +++ b/activemodel/lib/active_model/secure_password.rb @@ -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. diff --git a/activemodel/test/cases/secure_password_test.rb b/activemodel/test/cases/secure_password_test.rb index e59f00c8c5..9e68cceb5f 100644 --- a/activemodel/test/cases/secure_password_test.rb +++ b/activemodel/test/cases/secure_password_test.rb @@ -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' diff --git a/activemodel/test/models/user.rb b/activemodel/test/models/user.rb index cbe259b1ad..1ec6001c48 100644 --- a/activemodel/test/models/user.rb +++ b/activemodel/test/models/user.rb @@ -1,6 +1,5 @@ class User extend ActiveModel::Callbacks - include ActiveModel::Validations include ActiveModel::SecurePassword define_model_callbacks :create diff --git a/activemodel/test/models/visitor.rb b/activemodel/test/models/visitor.rb index 4d7f4be097..22ad1a3c3d 100644 --- a/activemodel/test/models/visitor.rb +++ b/activemodel/test/models/visitor.rb @@ -1,6 +1,5 @@ class Visitor extend ActiveModel::Callbacks - include ActiveModel::Validations include ActiveModel::SecurePassword define_model_callbacks :create |