File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -32,4 +32,45 @@ def has_secure_password
3232 klass_with . include described_class
3333 expect ( klass_with ) . to respond_to ( :has_secure_password )
3434 end
35+
36+ it "stores and authenticates a password digest" do
37+ klass = Class . new do
38+ include OmniAuth ::Identity ::SecurePassword
39+
40+ attr_accessor :password_digest
41+
42+ has_secure_password ( validations : false )
43+ end
44+
45+ instance = klass . new
46+ instance . password = "correct horse battery staple"
47+
48+ expect ( instance . password ) . to eq ( "correct horse battery staple" )
49+ expect ( instance . password_digest ) . to be_a ( String )
50+ expect ( instance . authenticate ( "wrong" ) ) . to be ( false )
51+ expect ( instance . authenticate ( "correct horse battery staple" ) ) . to be ( instance )
52+ end
53+
54+ it "clears the digest when the password is nil" do
55+ klass = Class . new do
56+ include OmniAuth ::Identity ::SecurePassword
57+
58+ attr_accessor :password_digest
59+
60+ has_secure_password ( validations : false )
61+ end
62+
63+ instance = klass . new
64+ instance . password = "secret"
65+ instance . password = nil
66+
67+ expect ( instance . password_digest ) . to be_nil
68+ end
69+
70+ it "tracks minimum bcrypt cost configuration" do
71+ described_class . min_cost = true
72+ expect ( described_class . min_cost ) . to be ( true )
73+ ensure
74+ described_class . min_cost = false
75+ end
3576end
You can’t perform that action at this time.
0 commit comments