Skip to content

Commit

Permalink
Merge pull request #16024 from aditya-kapoor/include-validations
Browse files Browse the repository at this point in the history
automatically include ActiveModel::Validations when include ActiveModel::SecurePassword
  • Loading branch information
rafaelfranca committed Jul 2, 2014
2 parents f625b68 + 7b1a42c commit a410427
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions 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.
Expand Down
5 changes: 5 additions & 0 deletions activemodel/test/cases/secure_password_test.rb
Expand Up @@ -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'
Expand Down
1 change: 0 additions & 1 deletion activemodel/test/models/user.rb
@@ -1,6 +1,5 @@
class User
extend ActiveModel::Callbacks
include ActiveModel::Validations
include ActiveModel::SecurePassword

define_model_callbacks :create
Expand Down
1 change: 0 additions & 1 deletion activemodel/test/models/visitor.rb
@@ -1,6 +1,5 @@
class Visitor
extend ActiveModel::Callbacks
include ActiveModel::Validations
include ActiveModel::SecurePassword

define_model_callbacks :create
Expand Down

0 comments on commit a410427

Please sign in to comment.