-
Notifications
You must be signed in to change notification settings - Fork 637
/
password_reset_test.rb
40 lines (37 loc) · 1.62 KB
/
password_reset_test.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
require File.dirname(__FILE__) + '/../../../test_helper.rb'
module ORMAdaptersTests
module ActiveRecordAdapterTests
module ActsAsAuthenticTests
class PasswordResetTest < ActiveSupport::TestCase
def test_before_validation
ben = users(:ben)
old_password_reset_token = ben.password_reset_token
assert ben.valid?
assert_not_equal old_password_reset_token, ben.password_reset_token
ben.reload
assert_equal old_password_reset_token, ben.password_reset_token
assert ben.save
assert_not_equal old_password_reset_token, ben.password_reset_token
end
def test_find_using_password_reset_token
ben = users(:ben)
assert_nil User.find_using_password_reset_token("")
assert_equal ben, User.find_using_password_reset_token(ben.password_reset_token)
assert ben.class.connection.execute("update users set updated_at = '#{10.minutes.ago.to_s(:db)}' where id = '#{ben.id}';")
assert_nil User.find_using_password_reset_token(ben.password_reset_token)
end
def test_reset_password_reset_token
ben = users(:ben)
old_password_reset_token = ben.password_reset_token
ben.reset_password_reset_token
assert_not_equal old_password_reset_token, ben.password_reset_token
ben.reload
assert_equal old_password_reset_token, ben.password_reset_token
ben.reset_password_reset_token!
ben.reload
assert_not_equal old_password_reset_token, ben.password_reset_token
end
end
end
end
end