aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel
diff options
context:
space:
mode:
authorAditya Kapoor <aditya.kapoor@vinsol.com>2014-07-03 02:51:12 +0530
committerAditya Kapoor <aditya.kapoor@vinsol.com>2014-07-03 02:51:12 +0530
commit7b1a42c05707c0e1f793bada3a448fd6f8630f5a (patch)
treeb8f0a24f6e45f58f4fff147cf61100bfd531775c /activemodel
parentc8f017682e507ba6cb4183c29cf9398a20211d15 (diff)
downloadrails-7b1a42c05707c0e1f793bada3a448fd6f8630f5a.tar.gz
rails-7b1a42c05707c0e1f793bada3a448fd6f8630f5a.tar.bz2
rails-7b1a42c05707c0e1f793bada3a448fd6f8630f5a.zip
automatically include ActiveModel::Validations when include ActiveModel::SecurePassword
Diffstat (limited to 'activemodel')
-rw-r--r--activemodel/lib/active_model/secure_password.rb1
-rw-r--r--activemodel/test/cases/secure_password_test.rb5
-rw-r--r--activemodel/test/models/user.rb1
-rw-r--r--activemodel/test/models/visitor.rb1
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