diff options
author | Robby Grossman <robby@freerobby.com> | 2012-07-31 16:16:21 -0400 |
---|---|---|
committer | Robby Grossman <robby@freerobby.com> | 2012-07-31 16:16:21 -0400 |
commit | ad7f9cdf008e1261fdcdc8e8152462f69b48c20d (patch) | |
tree | dbc0121154f4735273a432d624a9412988961915 /activemodel/test | |
parent | c10202208982bfa02ffd16d1614992228391d781 (diff) | |
download | rails-ad7f9cdf008e1261fdcdc8e8152462f69b48c20d.tar.gz rails-ad7f9cdf008e1261fdcdc8e8152462f69b48c20d.tar.bz2 rails-ad7f9cdf008e1261fdcdc8e8152462f69b48c20d.zip |
has_secure_password should not raise a 'digest missing' error if the calling class has specified for validations to be skipped.
Diffstat (limited to 'activemodel/test')
-rw-r--r-- | activemodel/test/cases/secure_password_test.rb | 8 | ||||
-rw-r--r-- | activemodel/test/models/oauthed_user.rb | 11 |
2 files changed, 19 insertions, 0 deletions
diff --git a/activemodel/test/cases/secure_password_test.rb b/activemodel/test/cases/secure_password_test.rb index 5f18909301..8650b0e495 100644 --- a/activemodel/test/cases/secure_password_test.rb +++ b/activemodel/test/cases/secure_password_test.rb @@ -1,5 +1,6 @@ require 'cases/helper' require 'models/user' +require 'models/oauthed_user' require 'models/visitor' require 'models/administrator' @@ -8,6 +9,7 @@ class SecurePasswordTest < ActiveModel::TestCase setup do @user = User.new @visitor = Visitor.new + @oauthed_user = OauthedUser.new end test "blank password" do @@ -73,4 +75,10 @@ class SecurePasswordTest < ActiveModel::TestCase @user.run_callbacks :create end end + + test "Oauthed user can be created with blank digest" do + assert_nothing_raised do + @oauthed_user.run_callbacks :create + end + end end diff --git a/activemodel/test/models/oauthed_user.rb b/activemodel/test/models/oauthed_user.rb new file mode 100644 index 0000000000..9750bc19d4 --- /dev/null +++ b/activemodel/test/models/oauthed_user.rb @@ -0,0 +1,11 @@ +class OauthedUser + extend ActiveModel::Callbacks + include ActiveModel::Validations + include ActiveModel::SecurePassword + + define_model_callbacks :create + + has_secure_password(validations: false) + + attr_accessor :password_digest, :password_salt +end |